There are two ways to kill application in Task Manager.
- Killing through Applications tab would roughly be equivalent of
SIGTERM
. Application may intercept it and do more processing, since it’s basically sending a “close window” message. Message to catch isWM_CLOSE
. - Killing through Processes tab would roughly be equivalent of
SIGKILL
. There is nothing you can do to intercept that, short of monitoring user’s actions in Task Manager’s listbox and End Process button, or having a watchdog process that will see when the first one is killed.
Alternatively, design the application in a way that does not require cleanup, or in a way that it will perform cleanup at startup.