There are several other reasons which may cause your Mac to shut down. All you need to do is simply disconnect every device attached to your computer and check if your Mac restarts and operates successfully without incident.
![mac shuts down when closing lid mac shuts down when closing lid](https://cdn.digitaldjtips.com/app/uploads/2021/06/22150135/nopowerfeat-1.png)
MAC SHUTS DOWN WHEN CLOSING LID HOW TO