Stop process using on close event and not exit. Exit does not guarantee that all stdout and stderr data is sent to the app.