call XShmDetach to allow X server to free shared memory.
This bug seems to be introduced with bcd80be4