Have a look at the clips which secure your CPU heatsink and fan assembly to the motherboard. These often go into plastic lugs mounted on the motherboard, and these can break. If the top one has broken it will allow the heatsink / fan assembly to hinge away from the back of the CPU. Since you say you have been suffering random shut-downs - often due to thermal overload - this sounds very possible.
If you do have this fault, the only permanent cure is a complete new plastic assembly on the motherboard. To the best of my knowledge, these plastic mounts are not supplied separately, but it would be worth your while contacting the manufacturer of your motherboard. There are only two sources I know. The expensive one is a new motherboard. The (much) cheaper one is to salvage one from a scrap mobo which uses the same mounting clip. It might be possible to chat up a local repair shop for a scrap board, or, if you have a recycling depot near you, see if you can get one out of a scrap computer.
There is a quick - but very dirty - fix which I used temporarily until I sourced a replacement clip. If it is the top lug which has broken, remove the fan / heatsink assembly, you may also need to dismount the CPU as well, remove the mounting bracket - usually four screws - and turn through 180 degrees so that the broken lug is at the bottom.. Then re-assemble.
You will also need to replace the thermal paste between the CPU and the bottom of the heatsink. This is essential.