A hacked up version of 'process.exit' that will first drain stdout
before exiting. *WARNING: This doesn't stop event processing.* IOW,
callers have to be careful that code following this call isn't
accidentally executed.

In node v0.6 "process.stdout and process.stderr are blocking when they
refer to regular files or TTY file descriptors." However, this hack might
still be necessary in a shell pipeline.
function drainStdoutAndExit(code) {
    if (_DEBUG) warn('(drainStdoutAndExit(%d))', code);
    stdout.on('drain', function () {
        cleanupAndExit(code);
    });
    if (stdoutFlushed) {
        cleanupAndExit(code);
    }
}