'Ends capture and truncates the captured sequence at `stop_time`.
Args:
stop_time: The float time in seconds to stop the capture, or None if it
should be stopped now. May be in the past, in which case the captured
sequence will be truncated appropriately.
block: If True, blocks until the thread terminates.
Raises:
MidiHubException: When called multiple times with a `stop_time`.'

def stop(self, stop_time=None, block=True):

    with self._lock:
        if self._stop_signal.is_set():
            if (stop_time is not None):
                raise MidiHubException('`stop`    must    not    be    called    multiple    times    with    a    `stop_time`    on    MidiCaptor.')
        else:
            self._stop_signal.set()
            self._stop_time = (time.time() if (stop_time is None) else stop_time)
            self._receive_queue.put(MidiCaptor._WAKE_MESSAGE)
    if block:
        self.join()
