When the CPU performs certain tasks it generates heat. The more intensive is the task the more is the heat generated. So to make the CPU cool, heat sink and fans are provded on the CPU as well as on the PC tower. But gradually dust accumulates in the tower and in the fan and reduces the effectiveness of the fan for cooling the inside of the tower as well as CPU. It might alos happen if CPU is kept in a closed place where there is no place for hot air to come out. Thus the processor gradually heats up and PC restrtas unexpectedly. This overheating also generate kernel error. This is a common problem in chips that have been overclocked to operate at higher speeds than they are supposed to.
So time and again clean the PC tower and place the tower in an open space where it can have sufficient air ventilation. Make sure you have atleast 3 fans (one on CPU, one on the tower and one on Power supply) and all are working fine. Specialist cooling fans/heatsinks are also available. Also do not over clock the CPU as it will reduce it’s lifespan.