you could put this in the users ~/.profile or ~/.bashrc (depending on the shell used):
# start ~/.profile
startx (or whatever you do to start the enviroment)
# end ~/.profile
this will start the X server and after logging out of X, the user will be logged out.
-= iluvatar =-