Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to close a GUI application in friendly "please quit yourself now" way, without graphical access to the applications window?

For example, if Gnome/X display crashes to black, I'd like to switch to tty2 and close applications like firefox in a way which lets them save their config etc. At best without further user queries.

share|improve this question
up vote 12 down vote accepted

Usually, you can use SIGHUP to "friendly" close an application (with or without graphical interface).

kill -HUP <application_pid>

EDITED: added some other info

The way SIGHUP is handled is application dependent so, as Dave noted, it can happen that this signal is masked or handled. However quite all interactive applications exit gracefully with a SIGHUP.

On the other side, I have to admit that usually I follow this schema:

kill -HUP <application_pid>
# check if application is still running
kill -INT <application_pid>
# check if application is still running
kill -KILL <application_pid>

Obviously the last command is not so "friendly".

share|improve this answer
If you don't know the PID of the application you can use pkill to specify the name of the executable instead. For example: pkill -HUP firefox-bin – Caleb Aug 26 '11 at 15:13
@Dave too: Interesting, I found this related which suggests a similar but reverted order: TERM->INT->HUP (mind the old age). Maybe I will keep HUP->INT->TERM in mind, as KILL doesn't seem to be friendly to me. Thanks to all. – jfk Aug 29 '11 at 9:03
@Caleb, just be careful there where there are multiple processes with the same name: pkill will kill them all. E.g., run this a few times to make some background processes: sed "s/Woo/woo/" < /dev/urandom >> /dev/null &. Then do pkill -HUP sed. You will kill all the instances of sed you started plus any other instances doing useful work. – ahcox Apr 7 '15 at 11:54

You may want to try:

kill -TERM <pid>


kill -TERM `pidof <application_name>`

At least on some systems, when the system is going through shutdown, all processes get sent the TERM (15) signal before they get sent the KILL (9) signal. HUP often just causes the application to reload its configs, but it can be different on a process-by-processes basis.

share|improve this answer

There's no general way to tell an application to exit and save its configuration. There may be ways to notify applications using a particular framework, e.g. dcop kfoo MainApplication-Interface quit for some KDE 3 applications. Mind that the application might show a dialog box asking you for confirmation.

If the X display becomes unusable, kill the X server. Press Ctrl+Alt+BackSpace; if that doesn't work, kill the X server process with sudo pkill -x Xorg. When the X server dies, all X applications are notified and they will try to exit gracefully (there's no guarantee that they will save everything, but it's your best bet).

share|improve this answer
I didn't know if the apps will be notified or just killed; and as the key combo isn't enabled by default on Fedora..... I now know how to kill it by command line! – jfk Aug 29 '11 at 9:13

Akin to @andcoz's answer, if you don't know the application's PID (I'm assuming you don't know it off by heart), try this:

kill -HUP `pidof [application_name]`
share|improve this answer
Take that one step frather and try pkill -HUP [application_name] :) – Caleb Aug 26 '11 at 15:13
Just learned pkill and pgrep :D – jfk Aug 29 '11 at 9:07

Two other commands you might want to consider are wmctrl -c and xdotool windowkill. I'm not sure whether windowkill is exactly what you're after, if not you might be interested in the windowdelete patch.

share|improve this answer

Your Answer


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.