It can be reproduced without external process: #include <GUIConstantsEx.au3> Opt("GUICloseOnESC", 0) $hGUI = GUICreate("Test Script", 300, 200) GUISetState(@SW_SHOW, $hGUI) WinClose($hGUI) WinKill($hGUI) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd And BTW, we can workaround this by sending Alt+F4 to the window: ControlSend($hGUI, "", "", "!{F4}") Or by cathing the WM_CLOSE message (wich is the best solution, it will cover up all the external attempts to close the window): #