This will work for Windows applications that have synchronous events available. You need to handle the main form Closing event. This is a synchronous event which you will receive prior to the application receiving it. If you cancel this event, the application will not close.
Note: Synchronous events are ones ending in "ing". So, Closed is asynchronous while Closing is synchronous. An asynchronous event will not cause blocking for the application, while a synchronous event will block the application while you perform automation.
Note #2: Synchronous events are not available for all applications. Test to see if you are able to block the application by responding to a synchronous event with a message box. If the application behaves normally, then most likely synchronous events are not supported for the apps technology.
All makes sense. Would this prevent the automation from closing the application if at any point you wanted it to do so? i.e. the automation has completed all tasks that you wanted it to. If so I presume there is no way around this.