Fix recognition of REPL disconnection