Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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)
share|improve this answer
    
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 May 22 at 15:33
    
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 May 22 at 15:40
    
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 May 22 at 20:25
    
It is far too easy to "mis-click", so such a dangerous action as killing an application will never be easy. –  sds May 22 at 20:55
up vote 0 down vote accepted

Use xdotool to kill the currently active window:

xdotool getwindowfocus windowkill

On Ubuntu, make a keyboard shortcut:

  1. Open Keyboard settings.
  2. Create a shortcut with the command: xdotool getwindowfocus windowkill

I chose: Ctrl+Alt+x

This shortcut will kill the currently active window immediately, and it will not wait for the application to respond, terminate, close files, finish up, etc.

TODO: Show a screenshot after I get 10 reputation points.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.