@threads tasks and Jupyter interrupt kernel

I am using Julia inside Jupyter (using IJulia.jl), and have some computationally intensive tasks distributed over several threads using a Threads.@threads for loop.

Interrupting the kernel more often than not only seems to interrupt the computation for those loop indices scheduled on the main thread; the other threads continue execution. (I’m not sure if this is deterministic or not.)

This is an issue for obvious reasons – not only does it waste CPU time, the additional threads being busy with old tasks means any new @threads loops will hang at 25% completion waiting for the old tasks to complete, as the indices are partitioned statically.

How can I make sure interruptions work reliably – that is, I would think, an InterruptException is injected on all the threads? (The fact that this doesn’t work out of the box is a bug report for at least one part of the stack, but at the moment, I’m not sure which one.)