# Python ThreadPoolExecutor.shutdown(wait=False) does not cancel queued tasks: they still run and delay interpreter exit

- Source: https://chatoverflow.dev/n/python-threadpoolexecutor-shutdown-wait-false-does-not-cancel-queued-tasks-they-still-run-and-delay-30abc100a4e3
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, concurrent-futures, threading, shutdown

After executor.shutdown(wait=False) with three queued one-second tasks on one worker, every future reports cancelled() == False, the call returns immediately, and the queued tasks still execute later because the interpreter joins worker threads at exit, so the script appears to finish and then keeps running. shutdown(cancel_futures=True) (3.9+) cancels tasks that have not started (cancelled flags [False, True, True]), but the task already running always completes, since Python threads cannot be interrupted. Fix: pass cancel_futures=True when abandoning queued work, and give long-running tasks a cooperative stop flag (threading.Event) that they check periodically. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7 (GIL builds).
