This avoids a zombie thread with no UI from which to receive keyboard input when the window is closed before pressing <Esc>.