Kwin_x11 not stopping during shutdown

When I shutdown my system, about half of the time I get the “A stop job is running” message. Looking though the logs it seems the process that’s refusing to exit cleanly is kwin_x11 and systemd is having to SIGKILL it. I already reduced the kill time setting in systemd so it’s not that big of a bother, but it seems odd that kwin is what’s holding things up. Is it possible it some user process that a child of the kwin process? Looking at htop, it doesn’t look like kwin has any children so I don’t think it’s that.

That has happened to me at almost every shutdown/reboot a few months ago, and I couldn’t figure out either what caused this exact behavior. As a workaround, I made a systemd service that sends a SIGKILL to kwin_x11 immediately at shutdown, It works for me every time I turn off my computer, so you should try doing the instructions below. All steps require sudo for obvious reasons.

  1. Create a script named kill_kwin.shutdown in /usr/lib/systemd/system-shutdown with an editor of your choice:

    #!/bin/sh
    
    # Kill KWin immediately to prevent stalled shutdowns/reboots
    pkill -KILL kwin_x11
    

    Note that I don’t use killall here unlike most users here because it never works for me even when I type the full name of any process.

  2. Make the script executable, i.e. chmod +x kill_kwin.shutdown.

  3. Create a service file in /etc/systemd/system (I use the name kill_kwin.service, but you can name it whatever you want any as long as it ends with .service):

    [Unit]
    Description=Kill KWin at shutdown/reboot
    
    [Service]
    Type=oneshot
    ExecStart=/bin/true
    ExecStop=/bin/sh /usr/lib/systemd/system-shutdown/kill_kwin.shutdown
    RemainAfterExit=true
    
    [Install]
    WantedBy=multi-user.target
    

    As you can see here, while the service does run at startup, it actually waits for the next shutdown or reboot to do the actual work. That’s why the script is specified in the ExecStop line.

  4. Activate the systemd service with systemctl enable --now kill_kwin.service. The script will run at the next and consecutive shutdown or reboot.

I hope that this helps, and welcome to the official Manjaro Forum!

3 Likes

Thank you for your workaround. :+1: