Fixing window cleanup segfaults in X11