Apple company has changed the behavior of the MacBooks in the clamshell closed with an external display in Mac OS X Lion, it was a special modification, which can be judged by the documentation: support.apple.com/kb/ht3131
This change completely canceled the ability to set the sleeping mode in the MacBook by closing its clamshell, if an external display is connected. They left no choice for the user.
Recently, on the forums of Apple has appeared the solution that returns the behavior as in Snow Leopard.
We should do the following in a terminal:
sudo nvram boot-args="iog=0x0"