diff --git a/rmw_zenoh_cpp/src/rmw_zenoh.cpp b/rmw_zenoh_cpp/src/rmw_zenoh.cpp index c9fa1f7b..dc86789d 100644 --- a/rmw_zenoh_cpp/src/rmw_zenoh.cpp +++ b/rmw_zenoh_cpp/src/rmw_zenoh.cpp @@ -326,7 +326,7 @@ rmw_destroy_node(rmw_node_t * node) // Erase the node from the set of session_nodes and close the Zenoh // session if this is the last node. node->context->impl->session_nodes_.erase(node); - if (node->context->impl->session_nodes_.empty()) { + if (node->context->impl->session_nodes_.empty() && node->context->impl->is_shutdown) { // Close the zenoh session if (z_close(z_move(node->context->impl->session), NULL) != Z_OK) { RMW_SET_ERROR_MSG("Error while closing zenoh session");