This sounds like the most logical reason as to why. When a CPU gets too hot, it shuts itself off so it doesn't take damage/die from extreme heat -- this is also true for a CPU getting too cold but you will never realistically hit such a cold temperature to shut your CPU off unless you are cooling it with liquid nitrogen. You probably noticed that your PC starts to slow down and then eventually shuts off, right? This is thermal throttling, where your CPU slows itself down to stop it from overheating but it won't always save it from reaching the cut off threshold which is what your PC is doing by shutting itself off. GPUs do this too. One minute you are running a game no problem, but then after a few hours, your fans on the card might be off or your case is just sweltering with heat, suddenly your FPS is spiking and dropping badly. That's because the GPU is now throttling itself to try and make sure it doesn't hit it's heat threshold.
Anyways, back onto your CPU. You mention the fan isn't spinning. Is this the stock cooler that came with the CPU or an aftermarket CPU cooler? Another thing is that the thermal compound may not have been applied correctly where there could have been too little, there could be pockets where there is compound and then some where there isn't or simply it wasn't put on at all. No thermal compound or a really poor job at it is a sure way to get your CPU to heat up badly.
What I would personally do, is buy some thermal compound - Arctic Silver 5 is what a lot of people use but I've been using Innovation Cooling Diamond 7 for a few years. It's thicker than Arctic Silver 5, which makes me feel a little more comfortable that I won't have excess and I've noticed that with Diamond, my CPU has always ran 5-7c cooler, while on my old i5-4690k, that thing ran 10c cooler which was so nice. If you need help choosing a thermal compound, you can post here for other recommendations or just look on Google for thermal compound with high and good reviews. From there, your CPU cooler. If it's a stock cooler, just get an aftermarket since the fan is dead (assuming it's dead, unless the cord is wrapped around it lol.) If it's an aftermarket fan that you had, check if you can RMA it since the fan is not spinning. Some CPU coolers come with pre-applied thermal compound, but I just said to get your own just in case there is not any pre-applied thermal compound. If you need any recommendations for an aftermarket CPU cooler if you are coming from a stock cooler; linking your PC build list would be a good idea. That way we know what socket it needs to fit and what type of case you have for headroom reasons such as room from the top and any optical drive bays that may be in the way.