Improve NaCl module exit handling and reporting.

This is a precursor to making it more convenient to close the window when Mosh
is done.
Allow closing of the window by pressing "x" once Mosh has exited.