def shutdown(self, *args, **kwargs) -> None:  # type: ignore
        """Shutdown backport from cpython 3.9 with interrupt support added."""
        with self._shutdown_lock:  # type: ignore[attr-defined]
            self._shutdown = True
            # Drain all work items from the queue, and then cancel their
            # associated futures.
            while True:
                try:
                    work_item = self._work_queue.get_nowait()
                except queue.Empty:
                    break
                if work_item is not None:
                    work_item.future.cancel()
            # Send a wake-up to prevent threads calling
            # _work_queue.get(block=True) from permanently blocking.
            self._work_queue.put(None)

        # The above code is backported from python 3.9
        #
        # For maintainability join_threads_or_timeout is
        # a separate function since it is not a backport from
        # cpython itself
        #
        self.join_threads_or_timeout()