title: nodejs express close server when request is done
body: <p>I'm writing a test script for my module and I need to be able to close my server when my request is done. The following code works but I can see that app.close() was dropped from express 3. What's the best way to do it now?</p>
  
  <pre><code>var testCase = require('nodeunit').testCase;
  var request = require('request');
  var express = require('express');
  
  var app = express.createServer();
  var srv = app.listen();
  ....
  
  request({
      method: 'POST',
      json: true,
      body: { id: 'second request'},
      url: 'http://' + target
    }, function(err, res, body) {
  
      console.info("closing server");
      app.close();
      test.done();
    });
  });
  </code></pre>
  
  <p>Thanks,
  Li</p>
  
  <p>p.s. test.done() must be called after closing the server, otherwise the test will fail.</p>