Oh I like this. It's pretty simple, both code and conceptually, that it seems obvious in retrospect.
It allows a function to be cancelled from the outside, but only on its own terms, and gives the function a chance to clean up after itself.
I'm going to use this