|To my knowledge, there are six things that can cause a PC to shut off suddenly, and three have already been stated.|
1) The heatsink for your CPU and its seating should always be checked, even if you think your PC isn't overheating. Temperature spikes can happen very quickly when your CPU is taxed. If the heatsink is off by even a fraction of a millimeter, positive contact over most of the apportioned CPU surface can be lost, and it could be that your setup has been "just getting by" as far as CPU temperature control is concerned. Also, if this is the case, then the constant higher temperatures will shorten the lifespan of your CPU thermal paste.
2) Power supplies are unpredictable animals. Bad power supplies can hide their faults if they stay plugged in all the time. One way to test if it's dying due to a bad capacitor is to shut your PC down and unplug the power cable, leaving it unplugged for at least a minute. If your PC doesn't respond immediately after plugging it back in and pressing the power button, then your power supply could be on its way out. The way to know for sure is to pull it, open the casing, and perform a physical inspecton of the capacitors. DON'T TOUCH ANYTHING INSIDE THE POWER SUPPLY IF YOU DO THIS. YOU CAN GET SHOCKED. If you see any capacitors with the tops starting to form an upward convex curve (bubbling) or if they have any corrosion on top whatsoever, then they're bad. Some people would say that you should have a higher wattage power supply for your hardware profile, but opinions differ on this.
3) Electrical short in the system. This one is harder to track down, but a lot of times it has to do with the way the motherboard is mounted to the case. Replacing metal mounting screws with plastic mounts is one way to fix this. Shorts can happen from almost anything, so the best thing to do is unplug EVERYTHING (including removing your RAM and any peripheral cards), check the connectors, and solidly reseat everything back into place. Double check the connections from any front panel items and the power switch to the motherboard, especially for any USB ports or card readers. Make sure you touch the metal of the computer case to expel any static charge you may have before touching anything in the computer.
4) Bad or loosely connected power cable. Sometimes it's just that simple. Some power supplies have sockets that are ever-so-slightly wider and the power cable never quite sits right. It'll always be a little loose no matter if it's in all the way or not. The easy way to fix this is to wrap the end of the power cable that inserts into the power supply with some electrical tape. It just happens to be the perfect width.
5) Bad wall outlet or power strip. It's rare that an outlet will fail on a decent surge protector or power strip, but if it's been abused you never know. Bad wall outlets, however, are a common occurrence. The only way to know is to buy an outlet tester. It's a small and handy tool that tells you if the outlet wiring is correct. They only cost $5. Everyone with electronics of any kind should have one of these, whether they live in a new house, old house, or apartment. If you value your gear, NEVER trust any outlet without testing it first. When you plug it in wiggle it up and down a few times to see if the lights blink on and off. If they do then you have an outlet that's shorting out (even if it's wired correctly).
6) Bad house or building power. To test this you need a multimeter. A cheap one is around $6-10 and will work fine. Power from your common 110v wall socket usually ranges between 118v and 122v, and it's not a set constant. You'll see the numbers fluctuate depending on what you have running on the circuit and there will be noticeable dips and spikes. Generally speaking, if you see your voltage dip under 117v or spike over 125v, you may want to move your PC to another circuit or buy a power conditioner. If you see your lights dim when the compressor in your refrigerator kicks on, that's a voltage sag. If they stay dim until the compressor turns off after a few minutes, that's a brownout. Either of those occurrences can permanently damage your electronics depending on the severity of the voltage drop.
Good luck, and hope this helps.