Thanks for your explanation Branko and hint about using the cancellation callback. I modified my C code to use it and it seems to do what I want. Unfortunately it doesn’t look like I can set the cancel callback with the Subvertpy library that I’m using, but I’ll see if I can add support for it.
Martin