If you just want the program to shut down and your using a GUI... use this.
Quote:
GuiClose: Launched when the window is closed by any of the following: pressing its X button in the title bar, selecting "Close" from its system menu, or closing it with WinClose. If this label is absent, closing the window simply hides it, which is the same effect as Gui Cancel. One of the most common actions to take in response to GuiClose is ExitApp; for example:
GuiClose:
ExitApp
Code:
~Pause::Reload
Reload
return
I use this to reload my scripts, but swap out the Reload for ExitApp and it will do the same thing.