If not already installed, install the dconf-editor, you can find it in the software center or in the terminal:
sudo apt-get install dconf-editor
Open it and navigate to:
org >> gnome >> settings-daemon >> plugins >> power
Activate the following checkbox and exit dconf-editor:
lid-close-suspend-with-external-monitor
Update: If the above instructions don't show the desired effect, open the following file:
gksudo gedit /etc/systemd/logind.conf
Uncomment (remove the # in) the following line and set it to 'suspend' instead of 'ignore':
HandleLidSwitchDocked=suspend
Save, Exit and Reboot