Summary:
Using `process.exit()` stops the node process without waiting for the event loop to finish, so when using async i/o, which is what happens when piped, if the output is buffered, the process can terminate before it finishes flushing the buffer.
This means you only get some of the output and the JSON is malformed.
This fixes it by calling `process.exit()` inside the flushed callback.
Reviewed By: passy
Differential Revision: D15624806
fbshipit-source-id: ea540ed5a40fb1811e5b705b190da96c8e54730d