def METHOD_NAME(self, event):
    """
    Gets called when the application wants to close the main window.
    We allow the plugins to cancel the close event in case they have
    unsaved state.
    Input:
        event[QEvent]: The event object
    """
    # closeEvent can get called multiple times, so this guard
    # just prevents going through all this again.
    if self._closed:
        return
    for name, plugin in self.tab_plugin._plugins.items():
        if not plugin.canClose():
            event.ignore()
            self._closed = False
            return
    self._cleanup()
    event.accept()
    QApplication.quit()
    self._closed = True