You have several problems here. #1, voltage spikes, these are "cured " by putting Zenamic or such like across the line. These are voltage dependent resistors, that go low resistance for a voltage overload. Their problem is that they will soak up large surges, provide they don't last too long. They are normally rated for pulses of up to 50 microseconds length. If you use a contactor or relay to try and disconnect an over voltage supply, they take 100 milliseconds or more to operate, so you will always have a hole in the protection regime. it should be possible to switch a triac on with a very low AC mains load (5 ohms?) if the device and resistor is mounted on a heat sink, it would protect for a few seconds or so.
To protect against brownouts (lights go brown - low voltage), you need to make a window detector, powered from you UPS which monitors the incoming AC and powers a relay to switch of the incoming mains if the voltage is too low or high.
Frank