Disable suspending the system when the lid is closed

Disable system-wide lid actions by editing /etc/systemd/logind.conf and see if it works (you can also use lock instead of ignore):

HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore

Apply changes: sudo systemctl kill -s HUP systemd-logind