Kill the currently active window with a keyboard shortcut
How can I kill the currently active window with a command or keyboard shortcut?
Alt+F4 closes a window, but first it will wait for the program to respond. Depending on the application, this may take several minutes. I am specifically interested in a solution with no waiting period -- that is, a solution that takes effect instantly.
I want to immediately kill the currently focused window with a shortcut.
Solution 1:
I think you are looking for xkill
.
Start it in a shell, then click on the offending window.
Alternatively, you can do Alt-F4 and wait - then you will be asked
the program is not responding - terminate it? (you will lose unsaved work)
Solution 2:
Use xdotool to kill the currently active window:
xdotool getwindowfocus windowkill
On Ubuntu, make a keyboard shortcut:
- Open Keyboard settings (shown below).
- Create a shortcut with the command:
xdotool getwindowfocus windowkill
I chose: Ctrl+Alt+x
This shortcut will kill the currently active window immediately. It will not wait for the application to respond, terminate, save, close files, finish up, etc.
Solution 3:
The default kill-window shortcut for me in KDE is Ctrl+Alt+Esc
(There's a separate Alt+F4 "close window" entry)
System Settings -> Shortcuts and Gestures -> Global Keyboard Shortcuts -> KWin