title: PyQt5: How to use closeEvent with a custom message-box
body: <p>Before I close my main window, I want to do some last operations.
  I think the <code>closeEvent</code> is the right thing to do that, but the standard QMessageBox does not suit my design, so I want to make my own (and I did). But with the following code, the application closes directly without showing my message-box.</p>
  <p>What here is the problem?</p>
  <pre><code>def closeEvent(self, event):
      self.messageBox = lastWindow(self)
      self.messageBox.show()
      return super().closeEvent(event)
  </code></pre>
  <p>This is the <code>lastWindow</code> code: (subclass of a pyuic5 generated .ui file):</p>
  <pre><code>from PyQt5 import QtCore
  from PyQt5.QtGui import QColor
  from PyQt5.QtCore import Qt, QPoint 
  from PyQt5.QtWidgets import QDialog, QGraphicsDropShadowEffect
  
  from UIs.UI_quit import Ui_Quit
  
  class lastWindow(QDialog, Ui_Quit):
      def __init__(self, parent = None):
          super(lastWindow, self).__init__(parent)
          self.setupUi(self)
          self._parent = parent
          self.setWindowFlag(QtCore.Qt.WindowType.FramelessWindowHint)
          self.setAttribute(QtCore.Qt.WidgetAttribute.WA_TranslucentBackground)
          self.setAttribute(QtCore.Qt.WidgetAttribute.WA_DeleteOnClose)
          self.shadow = QGraphicsDropShadowEffect(self)
          self.shadow.setBlurRadius(10)
          self.shadow.setXOffset(5)
          self.shadow.setYOffset(5)
          self.shadow.setColor(QColor(0, 0, 0, 80))
          self.mainFrame.setGraphicsEffect(self.shadow)
          self.btn_close.clicked.connect(self.abort)
          self.btn_quit.clicked.connect(self.destroy)
          self.btn_abort.clicked.connect(self.abort)
          self._parent.blur.setEnabled(True)
  
      def destroy(self):
          self._parent.close()
          self.close()
  
      def abort(self):
          self._parent.startService()
          self.close()
  </code></pre>