code: def keyPressEvent(self, event):
          
          if event.key() == QtCore.Qt.Key_Escape:
              self.reject()
  
          super(XOverlayWidget, self).keyPressEvent(event)
docs: Exits the modal window on an escape press.
  
          :param      event | <QtCore.QKeyPressEvent>