Respond to close instead of exit events

I observed a race condition when observing the 'exit' instead of
the 'close' event. Sometimes encryption would work, sometimes it
wouldn't. Debugging showed that the 'exit' event is sometimes
called before a 'data' event arrives.

The Node.js documentation actually states such behavior:

  Event: 'exit'
  Note that the child process stdio streams might still be open.
  http://nodejs.org/api/child_process.html#child_process_event_exit

  Event: 'close'
  This event is emitted when the stdio streams of a child process
  have all terminated. This is distinct from 'exit', since multiple
  processes might share the same stdio streams.
  http://nodejs.org/api/child_process.html#child_process_event_close

This commit switches from the 'exit' to 'close' events.