I'm working on a project to build a black box for my car using a Pi and various sensors (GPS, OBD2, dash cam, etc). So similar to your issue, it has to be running in the background when the car's on, but shut off when the car suddenly kills the Pi's power. Here's the solution I found. The Pi UPS: ht...