I would like to display a message before QgisQGIS close. But iI can't intercept the closeEvent of the main window from my plugin. I've tested this code which doesn't work.
# Main method
QgsApplication.instance().closeEvent = self.mainWindowCloseEvent
def mainWindowCloseEvent(self, event) :
# displaying message...
event.ignore()