Fix cancel atomicity

Follow-on from #2479.