Do not rule out "overheating" of the CPUs just yet.
If you have an older mac or mac mini ...download MacsFanControl to see if you are overheating!!! Set the settings to observe CPU1 temperature. Thats' the one that seems to get hottest. If it goes above 170 degrees or more..your fan might not be working. You can also watch the RPMs of the fan..if it doesn speed up...again..your fan will be dying..and it will give you the appearance of hardware problems..like mouse clicks or mouse moving on its own...constant shut downs.
The fan will only spin for so many years. This happened to a mac Mini late 2012..and it seemed like I was having weird mouse or hardware issues. It was that the mac was overheating and affecting the hardware..I also had constant shutdowns.