I have been going through old bug reports, and have moved this topic to Ask for Help.
I found NOTHING even similar to my problem.
Perhaps it's not a common mistake.
I feel this is entirely about the idiosyncratic way EXIT works in this context, and just wish there had been one small note about that.
Exactly what would you add to the documentation?
I would have thought that the presence of a tray icon would give away the fact that the script had not exited. It would be even more obvious if the script was single-instance, since a second attempt to run the script would tell you it is already running. If it is not exiting, there is no reason for OnExit to be called.
It seems that you assumed Exit would cause the entire script to exit; but why? I think the difference between Exit and ExitApp is already quite clearly documented. I don't understand why anyone would use Exit if the intention is to unconditionally exit the script.
ExitApp wrote:Terminates the script unconditionally.
Exit wrote:Exits the current thread or (if the script is not persistent and contains no hotkeys) the entire script.
If the script has no hotkeys, isn't persistent, and hasn't requested the Num/Scroll/CapsLock key(s) to be kept AlwaysOn or AlwaysOff, it will terminate immediately when Exit is encountered (except if it has an OnExit subroutine).
Otherwise, the Exit command terminates the current thread. In other words, the stack of subroutines called directly or indirectly by a menu, timer, or hotkey subroutine will all be returned from as though a Return were immediately encountered in each. If used directly inside such a subroutine -- rather than in one of the subroutines called indirectly by it -- Exit is equivalent to Return.
Use ExitApp to completely terminate a script that is persistent or contains hotkeys.