title: Node.JS Shutdown Hook
body: <p>Is it possible to intercept the default <code>kill</code> signal and use it as a command for a graceful shutdown? This is for Solaris SMF. The easiest way to have a stoppable service that I have found is to set <code>:kill</code> as the shutdown script and then to add a shutdown hook in Java. In this case, I want to do it for Node.JS. How should I do it?</p>
  
  <p>Edit: The purpose is to</p>
  
  <ol>
  <li>Stop receiving new requests.</li>
  <li>Give existing callbacks a few seconds to finish.</li>
  <li>Write some information to stderr.</li>
  </ol>
  
  <p>@alienhard's first suggestion was to use <code>process.on('exit'...</code> but it seems that I would not be able to accomplish number 2 with this method.</p>