MacBook crashes with so much of heat while the lid is closed
The system is designed to let the CPU idle when heat becomes an issue. Crashes indicate a bad software install or faulty hardware. Either of those can be worked out with Apple Support.

If you want to troubleshoot the software yourself, make a backup and then perform an erase install.


https://support.apple.com/en-us/HT204904


If you can crash the Mac with a clean install and no restore of your data or installation of third party apps - that's a perfect test to isolate hardware as the faulty item.