^+1 Using the software that came with your UPS, set the UPS up to commence shut-down so XP has time to close normally. If your UPS gives you 10 minutes on battery, shut-down after 5 minutes. Also, you can set the power in your BIOS, to resume after shut-down - so when the electricity comes on, your computer will re-start.