But I'm back to the problem of the IDE saying that the program is still running, even though it has stopped.
I check the button state and simply set gShouldStop = true; when the button is pressed.
The Build button on the IDE keeps circling. When I press STOP, it says "Stopping Bela" for a couple of seconds, then the message disappears and scrolls back to the original "Running project..." message.
I've reverted to the original WriteFile code, got rid of my version, so it should be as near to when it was behaving normally....
Bill