While it won't fix your overall problem, a UPS would have helped in this case. It would have kept your pump running during a short outage.
Though it also would keep everything energized until you could hit the off switch on the ups. Tradeoff.
Best to test your setup with poweroff/poweron a few times while you're standing there
54g all-glass bowfront corner planted FW
Red tiger lilly, Rotala Indica, Sagittaria Subulata, Micro Sword, Cardinal Plant
Fluorite Black sand and gravel