Ubuntu 20.04.3 LTS shutdown/restart/sleep not working

I have recently updated my ubuntu 20.04 LTS to Ubuntu 20.04.3 LTS.
After this update whenever I try to turn it off the screen becomes black but the PC don’t turn off.

PS: I have Microsoft Windows 10 alongside to this system and it turns off without any issues.

What is the problem?

There’s a considerable number of reasons why this might be happening.

Examples: a new kernel was installed and it’s not perfectly compatible with the kernel module (device driver) responsible for power control; you have SNAP installed and its daemon snapd is taking too long to stop and terminate itself (and systemd isn’t terminating it as it should); a shutdown task is repeatedly executed at shutdown but always fails to succeed and therefore is started again at every new shutdown attempt. And so on.

You need to power off your computer, then start it again and run dmesg and sudo cat /var/log/kern.log in order to check what’s causing this.

If you want to decrease the systemd timeout, you can edit the system.conf file:

sudo nano /etc/systemd/system.conf

…and then uncomment and edit the entries DefaultTimeoutStartSec, DefaultTimeoutStopSec e DefaultTimeoutAbortSec so they look like this:

#DefaultStandardError=inherit
DefaultTimeoutStartSec=10s
DefaultTimeoutStopSec=10s
DefaultTimeoutAbortSec=10
#DefaultRestartSec=100ms

Then save (Ctrl O), exit (Ctrl X) and restart to test it:

reboot

Try pressing Ctrl+Alt+K