There are settings in “dconf” to configure several types of actions when closing the lid, depending on whether the laptop is plugged in or not, but I don’t think they work — feel free to try them and let us know:
However, the advice given on this forum topic still works: