If you have IMAQ Vision then you can use the imaqGetLastEvent method, which returns the last event that the user performed on an image window. One of the parameters for this method is WindowEventType, which you can specify as IMAQ_CLOSE_EVENT to determine if a user closed a window.
I hope this helps. Best wishes!
Regards,
Dawna P.
Applications Engineer
National Instruments