Put it on a UPS [ uninterruptible power supply ]
What I did to stop that mess.