You can use the command line utility pmset to change the behavior of the lid closed/open state.
To disable wake/sleep on lid state:
sudo pmset -a lidwake 0
To undo the last setting
sudo pmset -a lidwake 1
By default, closing the lid will put the Mac to sleep. Setting the lidwake 0 value will disable it meaning closing the lid will do nothing.