def METHOD_NAME(self, timeout: Optional[float] = None) -> None:
    """
    In addition to flushing the queue, this method also calls the
    shutdown of the router.
    """
    start = time.time()
    # Commit all previously staged offsets
    self.__commit_function({}, force=True)
    for producer in self.__all_producers:
        producer.flush()
    while self.__queue:
        remaining = timeout - (time.time() - start) if timeout is not None else None
        if remaining is not None and remaining <= 0:
            logger.warning(f"Timed out with {len(self.__queue)} futures in queue")
            break
        committable, future = self.__queue.popleft()
        future.result(remaining)
        logger.info("Committing offset: %r", committable)
        self.__commit_function(committable, force=True)