fix case in which we can fail to exit the repl cleanly