Pc turning off

Hi, recently my pc has been randomly shutting off while I am mid-game. I think the problem is my cpu since it does reach max temp (95C), but it has only been doing this for the last two weeks. Do I need to get a new cpu and cooler or just a new cooler, or is there an other solution? Specs: •Ryzen 5 5600X (wraith stealth/stock cooler) •Gigabyte b550 gaming X v2 •Radeon rx 7800 xt • 750W coolermaster 80+ gold PSU