code: def event(self, event):
          
          if event.type() == QtCore.QEvent.Close:
              modifiers = self.app.queryKeyboardModifiers()
              shift_pressed = QtCore.Qt.ShiftModifier & modifiers
              states = self.app.controller.states
  
              if shift_pressed:
                  print("Force quitted..")
                  self.app.controller.host.emit("pyblishQmlCloseForced")
                  event.accept()
  
              elif any(state in states for state in ("ready", "finished")):
                  self.app.controller.host.emit("pyblishQmlClose")
                  event.accept()
  
              else:
                  print("Not ready, hold SHIFT to force an exit")
                  event.ignore()
  
          return super(Window, self).event(event)
docs: Allow GUI to be closed upon holding Shift