Pressing the button to end a CircleOS application is fine & dandy as long as you don't need the button for anything else. I've been using the following code to end my short demo programs:
If it looks familiar, that's because it's from the Cubic Tutorial project.
If you'd rather flip the unit over to clear it, ala Etch-a-Sketch, use this code:
A quick up & down shake of the STM32 Primer will also do the trick.
Enjoy!
Thanks,
Dale Wheat