title: Doing a cleanup action just before Node.js exits
body: <p>I want to tell Node.js to always do something just before it exits, for whatever reason — <kbd>Ctrl</kbd>+<kbd>C</kbd>, an exception, or any other reason.</p>
  
  <p>I tried this:</p>
  
  <pre class="lang-js prettyprint-override"><code>process.on('exit', function (){
      console.log('Goodbye!');
  });
  </code></pre>
  
  <p>I started the process, killed it, and nothing happened. I started it again, pressed <kbd>Ctrl</kbd>+<kbd>C</kbd>, and still nothing happened...</p>