title: Quitting node.js gracefully
body: <p>I'm reading through the excellent online book <a href="http://nodebeginner.org/">http://nodebeginner.org/</a> and trying out the simple code </p>
  
  <pre><code>var http = require("http");
  
  function onRequest(request, response) {
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write("Hello World");
    response.end();
  }
  
  http.createServer(onRequest).listen(8888); 
  </code></pre>
  
  <p>Now I didn't know (and I still don't know!) how to shut down node.js gracefully, so I just went <code>ctrl+z</code>. Now each time I try to run <code>node server.js</code> I get the following error messages.</p>
  
  <pre><code>node.js:134
          throw e; // process.nextTick error, or 'error' event on first tick
          ^
  Error: EADDRINUSE, Address already in use
      at Server._doListen (net.js:1100:5)
      at net.js:1071:14
      at Object.lookup (dns.js:153:45)
      at Server.listen (net.js:1065:20)
      at Object.&lt;anonymous&gt; (/Users/Bob/server.js:7:4)
      at Module._compile (module.js:402:26)
      at Object..js (module.js:408:10)
      at Module.load (module.js:334:31)
      at Function._load (module.js:293:12)
      at Array.&lt;anonymous&gt; (module.js:421:10)
  </code></pre>
  
  <p>So, two questions:</p>
  
  <p>1) How do I shut down node.js gracefully?</p>
  
  <p>2) How do I repair the mess I've created?</p>