Normally a Node.js script stops running when it reaches the end of the script and when there are no more event handlers waiting for events. What if you want the script to stop earlier?

It's quite easy.

The built-on process module has a method called exit:

examples/node/process_exit.js

process.exit(-1);

Comments

ctrl+C twice

or type:

.exit


nice


It was just what I was looking for. Thank you very very much