How turn off External Display, on closing lid in Ubuntu 20.04

I believe that there are a lot of questions asking the other way around. However for me, on closing my laptop's lid the external monitor is still running which I would like it to stop continuing to run,when I close my laptop lid.
Ubuntu Version: 20.04.1
I did the following things, However none of them seem to work:

  1. Edited /etc/systemd/logind.conf to the following:
HandleLidSwitch=suspend
HandleLidSwitchExternalPower=suspend
HandleLidSwitchDocked=suspend
  1. Changed the lid-close-ac-action option in dconf-editor under /org/gnome/settings-daemon/plugins/power to suspend

    EDIT:
  2. Changed the lid-close-suspend-with-external-monitor option in dconf-editor to true.

You need three configurations:

  • in dconf-editor org.gnome.settings-daemon.plugins.power the setting lid-close-suspend-with-external-monitor enabled
  • in file /etc/UPower/UPower.conf change the parameter IgnoreLid to true (ending up with IgnoreLid=true)
  • in file /etc/systemd/logind.conf you need HandleLidSwitchDocked=suspend