Fedora doesn't shut down when laptop lid is closed

I’m using fedora 42 kde, when I click shutdown and close the laptop lid, the computer doesn’t shut down properly. It just stays in a black page. I have to wait for the laptop to shut down completely before closing the lid, which is a pain. I know I can easily solve this by changing the behavior of the closing laptop lid. However, I quite like sleep mode. So, any work around?

In KDE system-settings you have several settings, one is for closing laptop lid and one is for clicking the shutdown button.

When you click shutdown and immediately close the lid the laptop will do whatever action is connected to closing the lid, probably sleep.

Look in system settings ==> Power management:

So when you want the laptop to shutdown instead of going to sleep or Turn off screen you can do several things:

Give the laptop time to shutdown before you close the lid
Remove the action for closing the lid