Cleanup on console closed & log error.stack

Added log of error.stack and cleanup when the Windows console close. 'Exit' seems not to be the right event to take async actions (from http://nodejs.org/api/process.html#process_event_exit), so I removed it.