def METHOD_NAME(self):
    """Call once from the main thread to stop the thread.
    After this returns no callback will be called anymore.
    """
    # wait until we fail or the observer tells us that the loop has started
    self._event.wait()
    # failed to create a tap, nothing to stop
    if self._tap is None:
        return
    # remove the runloop source
    Quartz.CFRunLoopRemoveSource(
        self._loop,
        self._runLoopSource,
        Quartz.kCFRunLoopDefaultMode
    )
    self._runLoopSource = None
    # remove observer
    Quartz.CFRunLoopRemoveObserver(
        self._loop, self._observ, Quartz.kCFRunLoopCommonModes)
    self._observ = None
    # stop the loop
    Quartz.CFRunLoopStop(self._loop)
    self._loop = None
    # Disable the tap
    Quartz.CGEventTapEnable(self._tap, False)
    self._tap = None