I want to tell Node.js to always do something just before it exits, for whatever reason — Ctrl+C, an exception, or any other reason.
I tried th
io.js has an exit and a beforeExit event, which do what you want.