Catch child exit, clean up the terminal and exit too.