sodcalculator

10 Tech How-To

How to Quit Frozen Programs in Linux

Guide 10-51270 · Updated · Step by step

When a program stops responding in Linux, you can usually recover without rebooting. This guide shows you several ways to force-quit a frozen application, from simple keyboard shortcuts to command-line tools, and how to avoid losing unsaved work.

What You’ll Need

  • A running Linux system with a graphical desktop (GNOME, KDE, XFCE, etc.)
  • Basic familiarity with opening a terminal (Ctrl+Alt+T on most distros)
  • Optional: xkill utility (usually pre-installed, but if not, install it via your package manager)

Step-by-Step

  1. Try the standard window close. Click the X button on the window’s title bar. If the program is only partially frozen, this may trigger a graceful shutdown and prompt you to save work.
  2. Use the keyboard shortcut Alt+F4. Select the frozen window (click it once) and press Alt+F4. This sends a close request to the window manager, which may work if the program’s event loop is still responsive.
  3. Try the system monitor. Press Ctrl+Alt+Delete (or Ctrl+Esc on some desktops) to open the system monitor. Find the unresponsive program in the process list, right-click it, and choose End Process or Kill.
  4. Use the xkill command (graphical). Open a terminal and type xkill. Your cursor will change to a cross or skull. Click on the frozen window to kill it. This forcibly terminates the X client connection, which often works even when the program is completely unresponsive.
  5. Find the process ID (PID) from the terminal. Open a terminal and run ps aux | grep program-name (replace program-name with the actual name, e.g., firefox). Note the PID number in the second column. Then run kill PID to send a SIGTERM, which asks the program to close gracefully.
  6. Force kill with SIGKILL. If the program doesn’t respond to SIGTERM, use kill -9 PID (or kill -SIGKILL PID). This forcibly terminates the process immediately. Use this as a last resort because it doesn’t allow any cleanup.
  7. Use pkill to kill by name. If you don’t want to find the PID, run pkill program-name to send SIGTERM to all processes with that name. For a forced kill, use pkill -9 program-name.
  8. Kill all instances of a program. If multiple windows are frozen, use killall program-name (or killall -9 program-name) to terminate all processes with that exact name.
  9. Reboot as a last resort. If the entire system is unresponsive, press Ctrl+Alt+F2 (or another F-key) to switch to a virtual console, log in, and run sudo reboot. If that fails, use the hardware reset button (hold power for 10 seconds).

Common Mistakes

  • Killing the wrong process. Always double-check the PID or name before using kill. Killing system processes (like systemd or Xorg) can crash your session.
  • Using SIGKILL too early. SIGKILL (-9) prevents the program from saving data or cleaning up temporary files. Try SIGTERM first.
  • Typing the wrong program name. pkill firefox will not kill firefox-esr if the name differs. Use pgrep -l firefox to list matching processes.
  • Forgetting to use sudo. If the process belongs to another user (like root), you may need sudo kill PID.
  • Clicking the X multiple times. This can make the program more unresponsive. Wait a few seconds after each attempt.

Tips

  • Save often. The best way to avoid losing work is to save frequently. Many editors have autosave features—enable them.
  • Use a lighter alternative. If a program frequently freezes, consider using a more stable alternative (e.g., a different web browser or text editor).
  • Check system resources. A frozen program might be due to high memory or CPU usage. Use top or htop to monitor.
  • Create a keyboard shortcut. You can bind a custom shortcut to run xkill for faster access. In GNOME, go to Settings > Keyboard > Custom Shortcuts.
  • Use the terminal efficiently. Learn the ps and grep commands well. For example, ps aux | grep -i chrome finds all Chrome processes.
  • Consider using a window manager with a kill shortcut. Some window managers (like i3) have a built-in shortcut to kill a window (e.g., Mod+Shift+Q).

Troubleshooting

  • What if the terminal is also frozen? Try switching to a virtual console with Ctrl+Alt+F2. Log in and run pkill -9 -u yourusername (replace with your username) to kill all your user processes, which may unfreeze the system. Then switch back with Ctrl+Alt+F1.
  • What if xkill doesn’t work? Some programs (especially games) may not respond to X client messages. Use the terminal method with kill -9 PID instead.
  • What if the program reappears after killing? This can happen if the program has a daemon or background process that respawns it. Use pkill -9 -f pattern to match the full command line, or stop the service with systemctl --user stop service-name if it’s a user service.
  • What if the system is completely locked up? Try the Magic SysRq key: hold Alt+SysRq and press R, E, I, S, U, B (with a few seconds between each). This safely reboots the system. If that fails, use the hardware reset.
  • What if the process is a zombie? Zombie processes (shown as Z in ps output) cannot be killed because they are already dead. They are cleaned up by their parent process. Reboot if they accumulate.
  • What if I don’t know the program name? Use ps aux --sort=-%mem | head -20 to see the top memory-consuming processes, which often include the frozen one.

Frequently Asked Questions

What is the difference between SIGTERM and SIGKILL?

SIGTERM (kill) is a polite request to terminate, allowing the program to save data and clean up. SIGKILL (kill -9) is a forceful termination that the program cannot ignore or handle, often leading to data loss.

Will I lose unsaved work when I force quit?

Yes, if you use SIGKILL or xkill, unsaved changes are lost. However, SIGTERM may give the program a chance to save. Always try to save work regularly.

Can I use the same commands on Wayland?

Yes, terminal commands like kill and pkill work on Wayland. However, xkill may not work because it relies on X11. On Wayland, use the system monitor or terminal commands.

Why does a program freeze in the first place?

Common causes include memory leaks, infinite loops, deadlocks, or waiting for a resource that never becomes available. Sometimes it’s due to a bug in the software or a conflict with another program.

Is it safe to kill a process as root?

Killing system processes can destabilize your system. Only kill processes you own or that you are certain are safe to terminate. Use sudo only when necessary.

How do I prevent programs from freezing?

Keep your system updated, avoid overloading memory, and close unused applications. If a specific program frequently freezes, report the bug to its developers or consider an alternative.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →