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"

This article will highlight some things that will do the work in the terminal more enjoyable and productive for users of MacOS X, and may be useful for users of other operating systems.
Visor
Visor is SIMBL- plugin for Terminal.app from BinaryAge, which allows opening a terminal using the hot key and it makes of it something like a console in Quake.
Installation. First of all we need SIMBL: www.culater.net / software / SIMBL / SIMBL.php
Then we download Visor from: visor.binaryage.com and unpack the archive, and put Visor.bundle in a folder ~ / Library / Application Support / SIMBL / Plugins.