Is there a way I could check to see if One program is trying to close another and Stop it if it is??

I was thinking it would use sendmessage and findwindow to kill the window.. But could I stop that process??

Thankyou!