But I understood the question as: what is the point program functionality ends, but before releasing any assigned resources until the program is totally finished.
ExitProc is called AFTER that.
You mean the program already released resources when ExitProc executes?
If that is the case why would you want to clean up? The program already did that
So there is no need for further clean up.
Anyone know how to detect when a program terminates to run code to clean up?
But I think ExitProc executes before the program has cleaned up anything. So freeing unreleased memory or handles can still be done there.
But like you said, using proper try/finally or the correct events (if you use TApplication) is of course preferred.