Is there a callback I can use to run some cleanup code for my application before shutting down when using the double tap of the mode button?
You might be able to listen to button_final_click
and check that it’s 2 and do stuff:
https://docs.particle.io/reference/firmware/#system-events-overview