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()

```