How to wait for a program termination signal/attempt, and stop it from termination?

view story

http://stackoverflow.com – Let me explain exactly what I'm trying to achieve. I want to write a bash script which will be "watching" some application. As soon as an attempt is made to close/terminate this application, the script will try to stop that termination operation for a few milliseconds, do some stuff and then terminate the application. (HowTos)