def shutdown(self, wait=True):
        """
        Shut down the worker message handler and scheduler threads.
        Args:
            wait: If true, block until both threads have successfully shut down. If False, return immediately.

        Returns: None

        """
        self.scheduler_thread.stop()
        self.worker_message_handler_thread.stop()

        if wait:
            self.scheduler_thread.join()
            self.worker_message_handler_thread.join()