The way the sleep action works on XFCE currently is to call xflock4.

xflock4 is called before sleep if "Lock screen before sleep"
option is enabled in KShutdown.

This will successfully lock the screen, but nothing happens after that.

Maybe I should also try to add support for suggested "xfce4-session-logout --suspend"
in case all other (systemd, UPower, etc.) sleep functions fail.

When I type in my password to unlock the screen, then the system immediately goes to sleep.

Hmm... This is weird. I fixed some Xfce bugs years ago,
but I don't remember if this one is related.

If the problem still exist in recent KShutdown 5.2 please send me the log output
(quit KShutdown and run it in a Terminal or search in ~/.xsession-errors file)

Thanks