I'm writing an application running under X (using Motif), and I need to do
some stuff when the application quits.  Now, when I shut down my X Windows
session, it doesn't seem to send a SIGTERM (or whatever) signal to my
application (I'm trapping various signals like that).  Therefore, I thought
I could use an X signal to check for my top level window being destroyed.

However I seem to get DestroyNotify events whenever I move windows.  Is
there any way for me to check that the window is actually being destroyed
(some field to check or some combination of events?).

Replies by e-mail please and I will summarise.

Thanks for any help,
                      Ian