TerminateApp: Close, don’t kill that app
May 11th, 2009Recently when automating certain tasks, I came across the need for a command line app that would close windows applications in a clean way. After a lot of searching I was surprised not to find something to do this simple task. Yes there a lot of tools to kill an application, but that was not what I was looking for.
Why?
Well, a lot of applications perform a lot of important tasks before they close. These range from saving settings, asking you to save files, releasing hooks. Whatever the task may be, if you killing an application stop it dead in it’s tracks and the app does not have a chance to perform these tasks.
So TerminateApp is the result of this necessity.
You can specify the process by it’s name or by it’s process ID. If you really are impatient, you can even kill the application if the application refuses to terminate within a given amount of time.
How does it work?
TerminateApp sends a WM_QUIT message to all window handles within a specified process. So it will only work for applications that process the WM_QUIT message. This worked fine for the several applications I tested it on, but I cannot guarantee it works on all the apps out there. This would depend on the way the app has been written.