Form_QueryUnload. Since you specified the MDI application, the exact event triggered:
Private Sub MDIForm_QueryUnload(cancel As Integer, unloadmode As Integer)
where, if you set cancelto a non-zero value inside this function, it stops exiting the application. In other words, QueryUnloadthis is a way of asking if the form should be unloaded or not. The second argument unloadmodegives you information about how this unloading was started.
MSDN.