Well if you would return to your first idea of powering the 328P directly from the battery below is a proof of concept sketch that Coding Badly and I worked on a couple of years ago that allows a sketch to directly determine the actual value of the voltage applied to it's Vcc/Avcc pins. It uses the known internal band-gap reference as a way to 'back calculate' what the applied Vcc must be at any given time.
Of course that still leaves you with a means of how you are going to disconnect the battery once you have performed all the orderly shutdown tasks.
But I'm not running it directly from the battery. The mega328 will get a regulated 3.3V from a step-down/boost converter. I've shown this on the schematic above on my original post. That means I can't just read the internal band gap voltage to get the voltage at Vcc because Vcc (assuming the boost converter is working properly) will be regulated to 3.3V regardless of the battery voltage.