pub fn teardown_managed_window(
        &mut self,
        h: WindowHandle<X11rbWindowHandle>,
        destroyed: bool,
    ) -> Result<()> {
        let WindowHandle(X11rbWindowHandle(handle)) = h;
        self.managed_windows.retain(|x| *x != handle);
        if !destroyed {
            xproto::grab_server(&self.conn)?;
            self.ungrab_buttons(handle)?;
            self.set_wm_state(handle, WMStateWindowState::Withdrawn)?;
            self.sync()?;
            xproto::ungrab_server(&self.conn)?;
        }
        self.set_client_list()?;
        Ok(())
    }
Teardown a managed window when it is destroyed.
display-servers/x11rb-display-server/src/xwrap/window.rs