The escape mechanism is really bad, but the best I could come up with under the circumstances. All Grasshopper solutions run on the UI thread meaning that mouse and key events aren’t handled until after the solution completes.
To get around this I sometimes check the state of the escape key directly. However if you’re unlucky there can be many seconds or even minutes between these checks. So instead of asking windows if the escape key is down right now, I ask whether the escape key has been pressed since last I asked.
There’re no words for how nasty a hack this is, and now that I think about it there should have been a way to just disable this testing.