When the lid is closed, the operating system receives an ACPI event. You can configure how Linux responds to this ACPI event: by default, in your setup, this triggers suspension, so you need to change that.
On Ubuntu, in the Gnome control center, you can configure what happens when the lid is closed in the “Power” tab. Change it from “Suspend” to “Do nothing”. This only affects what happens when you're logged in on the console.
To change the system default, you can edit the file
/etc/acpi/lid.sh. It should be enough to create a file
/etc/acpi/local/lid.sh.pre and implement your desired behavior there — though looking at it on Ubuntu 12.04, I think that what you want is the default behavior when not logged in (I haven't tested). How to prevent screen locking when lid is closed? and How can I tell Ubuntu to do nothing when I close my laptop lid? may have useful complementary information.