Backport `drain_worker_queues` from remove-thread-raise.