Actions to take when closing the laptop lid are configured with command gnome-power-preferences (menu: System -> Preferences -> Power management)
You will need to set two options: "When laptop lid is closed" to "Do nothing", and also "Put computer to sleep when inactive for" to "Never" (otherwise the laptop won't sleep automatically when you close the lid, but will soon afterwards because it's inactive). Note that these options have separate values for "AC power" and "Battery power": of course, you'll have to configure the correct one for your case (or both).
*Note: You may have to run the following command for the option to show up:
gconftool-2 --type string --set /apps/gnome-power-manager/buttons/lid_ac "nothing"