Hi James,
I'm sorry to hear you are running into PC issues. While there certainly are similar issues that have been observed by other PC users, troubleshooting the issue and potentially fixing it not only can be time consuming but also requires the proper knowledge in order to do so. The bottom line, there's no simple answer to your question.
With that said, you may want to consider signing up for a free PC-Doctor Toolbox Remote account here:
https://www.pcdtoolbox.com, which will provide you with 5 free PC-Doctor Toolbox licenses. Using PC-Doctor Toolbox you can then run a full system diagnostics scan, and perhaps this will single out the faulty piece of hardware causing the issues. If it does you can then consider replacing that piece of hardware to resolve the issues (some instances require more work than just replacing the defective hardware).
Please also keep in mind that not all PC issues can be detected with a single piece of software. While PC-Doctor Toolbox has the capability of testing a majority of a computers hardware (e.g. CPU, Hard Drive, Memory), you may be dealing with a software issue. For software issues you can restore your Operating System for a potential fix, but again there is no guaranteed solution.
Lastly, because your machine is randomly shutting off entirely I do worry that you are dealing with a pretty serious issue. Depending on the age of the machine in question, it may be worth replacing the device rather than repairing it.
Hope this helps,
Dan R.