You may have a heating problem. Check your fan in back. Open the cover and make sure the CPU fan is spinning when the power's on. Also, see if there is a lot of dust. If so, get a can of compressed air and clean it out. If your computer over heats, it can do this.
Another problem might be your power supply. Some of them last forever, others go bad quickly, but most wear out after a few years if the computer is used a lot. When they do, they can cause all sorts of problems, from the computer shutting down, to memory errors and so on.
The main thing is, if it happens in both windows and Linux, then it's likely a hardware problem. There are other things that can cause this, a bad motherboard, faulty memory, a wire shorting against the case, and so on. More than likely, however, it's either a cooling problem or a power supply, and both are low-cost fixes.
If you're not using an uninterruptible power supply or at least a surge protector, this can happen as well, because the power coming from your electric company isn't very stable.