Kill the currently active window with a keyboard shortcut

9

5

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.

Kamil Slowikowski

Posted 2014-05-21T18:26:45.260

Reputation: 261

On certain KDE applications in Linux, Ctrl+w closes the current focused window. – Eric Leschinski – 2017-01-26T18:33:23.707

Answers

6

Use xdotool to kill the currently active window:

xdotool getwindowfocus windowkill

On Ubuntu, make a keyboard shortcut:

  1. Open Keyboard settings (shown below).
  2. 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.

Keyboard Settings

Kamil Slowikowski

Posted 2014-05-21T18:26:45.260

Reputation: 261

10

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)

sds

Posted 2014-05-21T18:26:45.260

Reputation: 1 600

1what about ctrl+q? That closes the active window (i guess with signal SIGTERM). On Windows is ctrl+w. – m3nda – 2015-05-22T08:35:54.497

Thanks for the answer! I would prefer to use a keyboard shortcut instead of opening a shell, typing a command, and then using my mouse to find the window. When I open a shell, it might overlap or hide the offending window. I think it's much easier to use a shortcut. – Kamil Slowikowski – 2014-05-22T15:33:55.973

In that case you should use Alt-F4 or click on the "x" in the upper right(or left) corner. After a while, you will be asked the "terminate it?" question. – sds – 2014-05-22T15:40:02.633

In theory, you're right. In practice, I don't have time to wait for the application to respond. Sometimes it takes minutes before such a "terminate it?" question pops up. After clicking "terminate it" then I have to wait even longer. I'm looking specifically for a solution that avoids waiting. – Kamil Slowikowski – 2014-05-22T20:25:52.777

It is far too easy to "mis-click", so such a dangerous action as killing an application will never be easy. – sds – 2014-05-22T20:55:26.610

3

The default kill-window shortcut for me in KDE is Ctrl+Alt+Esc

enter image description here

(There's a separate Alt+F4 "close window" entry)

System Settings -> Shortcuts and Gestures -> Global Keyboard Shortcuts -> KWin

jozxyqk

Posted 2014-05-21T18:26:45.260

Reputation: 1 960