I found that killing the X server or the window manager won work well to end X11. How can I shutdown X11?
Yes, we know it is a problem, mainly related to signal handling that is not fully compatible to Unix signaling as well as some differences in session semantics. XFree86 is not really intended to be started up and shutdown all the time (this is BTW bad manner of users who were accustomed to have only one program open under Windows, because a second one would fail running out of resources). If you don’t need XFree86 for a moment, just leave it running in the background – eventually it will be completely swapped out in the swapfile, and you won’t need to bother about it eating up resources). Part of the problem is that clients started in xinitrc.cmd remain under PM control (i.e. its parent is PM, not xinit, as intended), so when X goes down, it doesn’t destroy these clients with it.