diff --git a/zenoh/src/session.rs b/zenoh/src/session.rs index eaca07d964..9ff91ea990 100644 --- a/zenoh/src/session.rs +++ b/zenoh/src/session.rs @@ -529,10 +529,11 @@ impl Session { self.runtime.close().await?; } let mut state = zwrite!(self.state); - state.primitives.as_ref().unwrap().send_close(); // clean up to break cyclic references from self.state to itself - state.primitives.take(); + let primitives = state.primitives.take(); state.queryables.clear(); + drop(state); + primitives.as_ref().unwrap().send_close(); self.alive = false; Ok(()) })