Hi,
There is no On_Form_close event in InfoPath. Therefore, you can force your user to use a close button on your form. In there, you can check the thisApplication.ActiveWindow.XDocument.IsDirty flag to see if anything needs to be saved. Next, you can use System.Windows.Forms.DialogResult to display a customized message box. Based on the answer from your user, you can proceed and Save or Close the form without saving.
Does it make sense?
Regards,
Franck Dauché