Design power off to prevent brown out - best practices asked

I’m making a light product and people should be able to pull the power directly (just with the main switch). Of course I don’t want to lose important stuff. I was reading about EEPROM data that gets corrupted:

Are there any good practises to detect of a power supply is switched off? For example with a voltage sense circuit. Can I monitor that with an interrupt? And what then? Can I reset or do something else with the Photon (what?).

Adding a capacitor so the Photon still gets a bit of juice to shut everything down correctly?

Any best practices are welcome.