Added ESC catching for window closing.