Force macbook to sleep when lid closed and external monitor connected in Lion
This worked in 10.7 and 10.8 with my MacBook Air:

sudo nvram boot-args=iog=0x0


After restarting, it should restore the pre-10.7 behavior:


Closing the lid puts a laptop to sleep even when it is connected to an external display
If you then wake the laptop up and open the lid, the internal display doesn't turn on


To undo it, run sudo nvram -d boot-args or hold ⌥⌘PR on startup.