more robust repl.close routine - fixes #8