diff --git a/lib/wp/endpoint.c b/lib/wp/endpoint.c
index 32a3036b996420274c2acd5400c055a5032a6b12..83db67761d363a8f8951680667189b65d8a79c99 100644
--- a/lib/wp/endpoint.c
+++ b/lib/wp/endpoint.c
@@ -279,8 +279,8 @@ wp_endpoint_unregister (WpEndpoint * self)
     g_info ("WpEndpoint:%p unregistering '%s' (%s)", self, priv->name,
         priv->media_class);
 
-    priv->core = NULL;
     wp_core_remove_global (priv->core, WP_GLOBAL_ENDPOINT, self);
+    priv->core = NULL;
   }
 }