Close the window when the shell exits