Almost certainly a heat issue. I come across this quite often. I'll be more detailed than you probably need in case of others having the same problem.
First, take a powerful vacuum pipe to all outside air holes.
Then, leave the mains power plugged in, but switch off at the socket. That will earth the chassis to prevent static. Touch the chassis metal to be sure of earthing yourself.
Now open the side, normally two screws will do it, sometimes it is a sliding lever arrangement. You want the side furthest away from the USB/mouse/keyboard sockets - ie the side above not below the mainboard.
You should see a large fan facing you on the board - the CPU fan. Probably you can see the heatsink fins below it are clogged with dust. Place the vacuum pipe over the fan and suck up the dust. You might need a small brush, but earth it to the chassis first.
There could be a case fan, often at the back inside at 90 degrees to the CPU fan. Clean if necessary, but you also need to check it does not pull air away from the CPU fan - they often do this by blowing air out of the back of the chassis very close to the point that the CPU fan is trying to suck air downwards over the processor. To test if the fan is blowing out of the case put your hand over it at the back with the computer on - before you open the side preferably. Don't mistake the psu fan (always at the top of the case back) for a case fan.
You can either leave it anyway once the dust is cleaned, or you would need to unscrew the four self tapping screws into the case fan plastic on the back of the case. Then flip the fan over to reverse its direction and they will screw in no problem.
What you want is airflow in to the case (with or without a case fan) down through the cpu fan and out through the power supply fan.
There is a possibility that the psu is on the way out, but not likely based on the symptoms you've described ie. instant cutouts after a while.