To close a display or disconnect from the X server, use XCloseDisplay().
Xlib provides a function to permit the resources owned by a client to survive after the client's connection is closed. To change a client's close-down mode, use XSetCloseDownMode().