Random shutdowns are often caused by overheating - - shutdown protects the vital components from permanent damage.
The PC case interior & components could be ready for a good dose of compressed air to remove build-up of dust, especially around any fans & heatsinks. Use one of those cans of compressed air designed for that purpose.
Whilst your inside the case, power-up the system and check that all the cooling fans are actually working, but don't have the system running when you clear the dust out of it.
Make sure all the air intake/exhaust vents on the case are clear too.