Windows 7 has a feature using which you can choose desired power settings, when a laptop is closed. This is available under the Control Panel -> Power Options.
Click Start menu -> Control Panel -> System and Security.
This would display the following window.
Navigate to Power Options and click the link with label as Choose what closing the lid does
In the Define power buttons and turn on password protection window, choose the desired option for When I close the lid dropdown. The available dropdown values are Do nothing, Sleep, Hibernate, Shut down. After selecting the value for the drop down, click Save changes button to confirm and save your selection.