PTY ending with 'exit' event instead of 'end'