Like almost everything in X, the way to quit X is configurable. The
key to shutting down X is to know which of your programs (your windows
or window manager) is the controlling program
. When the
controlling program quits, any leftover X programs are killed
immediately. The controlling program is usually either the window
manager or the single xterm
window that started your X session.

Find the controlling program for your X session and write it down:

_____________________________ Program to quit last

If your controlling program is an xterm
window, we suggest
leaving that window iconified from just after you've logged in until
you've shut down all the other X clients. That way, you won't end
your X session accidentally by closing that xterm
window too
soon.

To quit the window manager, select the Exit
or Quit
command on
the root menu.

Here are the steps to shut down X:

Quit all noncontrolling programs (all programs other
than the
controlling program).
If any windows are running programs that have their own "quit" commands,
it's a good idea to use those special commands to quit.
For example, if you're running a text editor in an xterm
window,
use the editor's "quit" command, then finish the xterm
window by
entering exit
at the shell prompt.

Using the program's own "quit" command gives the program time to clean up
and shut down gracefully.
On the other hand, the Close
item on the mwm
window menu
can interrupt and kill a program before it's ready.
If, however, a program doesn't have its own "quit" command, use Close
on the window menu.

If any icons are running programs that have their own "quit" command,
open the icons into windows and use the "quit" commands.

Quit the controlling program.

After X shuts down, you may get a UNIX shell prompt.
If you do, you can log out by entering exit
.
If you simply get another login box from xdm
(as in Figure 2.2
), you're done.