Open /etc/systemd/logind.conf file for editing
vi /etc/systemd/logind.conf
Find the line #HandleLidSwitch=suspend.

Remove the # character at the beginning of the line.
Update this line to any of the desired settings below:
- HandleLidSwitch=poweroff to shutdown computer when lid is closed
- HandleLidSwitch=hibernate to hibernate computer when lid is closed
- HandleLidSwitch=suspend to suspend computer when lid is closed
- HandleLidSwitch=ignore to do nothing to do nothing
Save the file and restart the service to apply the changes
systemctl restart systemd-logind