If you have LV 6.1 or newer you can use an event structure to catch and discard the close, closing the VI in a controlled fashion using your own code (with the save dialog etc.).
Create an event structure, add an event case for the VI Panel close? event, wire a true to the discard terminal and do whatever you want to do inside that case, or set a flag there that you act on somehwere else...
If you have LV5 I may be able to find a VI for you that will do the trick though.