I would like to display a message before Qgis close. But i 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()