Have you considered any of the raspberry pi power button options that exist? Something with a reasonable size capacitor and a signal pin to let the Pi know to shutdown when it's lost power, before the capacitor runs out, might work?
Yes capacitor power button would work (assuming it is reliable). Still an amount of faff and expense to set up, especially if you are scaling a deployment. It would be great if the RPi (or some version of it) had this 'pre-installed'.