Though this is a late answer, I found this from NodeJS docs:
The 'exit' event is emitted when the REPL is exited either by receiving the
.exit
command as input, the user pressing<ctrl>-C
twice to signal SIGINT, or by pressing<ctrl>-D
to signal 'end' on the input stream. The listener callback is invoked without any arguments.
So to summarize you can exit by:
.exit
in nodejs REPL.<ctrl>-C
twice. <ctrl>-D
. process.exit(0)
meaning a natural exit from REPL. If you want to return any other status you can return a non zero number. process.kill(process.pid)
is the way to kill using nodejs api from within your code or from REPL.