Preventing MacBook from sleeping when closing lid on Sierra
InsomniaX works perfectly on my MBP 13" 2015. I am using macOS Sierra 10.12. 

There's also an app called NoSleep, but it hasn't been updated in years, only use it if you're on older OSX like Mavericks or Yosemite.. I wouldn't recommend using it on Sierra..



UPDATE: 1st FEB, 2020
InsomniaX is not being mantained anymore &amp; you SHOULD NOT use it. No sleep is a better option until MacOS Mojave. Haven't tested any of these with MacOS Catalina. If anyone has tested with Catalina, let us know in the comments.