Macintosh laptops will go to sleep when the screen is closed. If this is not intended, you can install a tool so that it will stay powered on.
A Macintosh laptop with Intel, Mac OS X 10.6.6 or later and NoSleep, downloadable from: https://www.macupdate.com/app/mac/37991/nosleep
Visit NoSleep’s download page or Developer Site to get the 1.2MB NoSleep installation file. Run the installer (you may need your user’s password). You can optionally install the command line interface (CLI) package for scripting purposes.
Once the installation is complete, you can view the NoSleep icon in the toolbar at the top right of your screen. If you click this, then go to “Preferences…“, you can change various options, such as whether the Macintosh should “Never sleep on AC Adapter“, “Start NoSleep utility on system startup“, “Require password on display opening“, etc.