Faced with having to manually delete two lock files created in /tmp by Apple's X11 that should be deleted when x11.app is quit, I needed to put remove commands into a script that would only be run when logging into or out of the console. This couldn't happen for individual shells (so using /etc/csh.login or /etc/csh.logout wouldn't work). I could not find the answer in OS X Unleashed or other good books.
Gary Karbaugh pointed out to me that you can add a -LogoutHook and/or a -LoginHook switch to the console line of the /etc/ttys file. The switch takes an argument that is a full path to whatever script you want to run when you logout. Apple documents this here with an example. In my case the script was to delete /tmp/.X0-lock and /tmp/.X11-unix/, both of which were preventing me from making available X11.app for more than one user, a mysterious bug that plagues some but not others.
I found I had to restart to get it to work, though I imagine there is a more elegant way.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20030116061349986