Mac not sleeping when lid is closed
Do not  blindly start typing copying/pasting stuff into the prompt without knowing what you're doing this could seriously hinder performance or destroy your system!! 

Fire up a terminal window either through cmd+space and typing into spotlight Terminal.app or Finder > Applications > Utilities > Terminal

I'd modify the energy settings via pmset.You can get your current settings with pmset -g. My energy preferences are something along the lines of:

sudo pmset -a destroyfvkeyonstandby 1 
sudo pmset -a standby 0
sudo pmset -a sleep 20
sudo pmset -a displaysleep 20
sudo pmset -a proximitywake 0 
sudo pmset -a acwake 1
sudo pmset -a lidwake 1 
sudo pmset -a powernap 0 
sudo pmset -a networkoversleep 0
sudo pmset -a womp 0 
sudo pmset -a ring 0
sudo pmset -a standbydelay 0
sudo pmset -a autopoweroff 1
sudo pmset -a autopoweroffdelay 0
sudo pmset -a tcpkeepalive 0
sudo pmset -a ttyskeepawake 0


From man pmset:


  -a = all (all options being passed to power manager should apply to battery, ac connected or UPS, connected machine)


Keep in mind these settings will affect the entire machine; so I'd read up if you're not familiar with them. Eg. tcpkeepalive will kill off network connections; thus, Find My Mac won't be available when the machine is offline [for me, this ain't a problem; though, to each, his own. ]

Also proximitywake causes nearby devices to automatically connect and share info with nearby Apple devices that are sharing the same iCloud account (that's, if you're willing to buy into what apple is supposedly telling you through the man pages -- don't know about you but when I turn something off; I want it OFF.)

NOTE: from what I remember, proximitywake is a feature introduced prior to 10.13 (High Sierra); so it might not be available with El Capitan(Don't know  though...with all the security updates... you're gonna have to run pmset -g and man pmset in order to figure it out.)

Remember that the man pages are your friend! Whenever you're inside a terminal prompt and aren't sure about what a cmd does; type man &lt;desired_cmd&gt; in order to get the details about what does what. Type q to exit it.