n->connection->outgoing = NULL;
                        }
 
+                       /* Remove the edge before terminating the connection, to prevent a graph update. */
+                       edge_del(mesh, n->connection->edge);
+                       n->connection->edge = NULL;
+
                        terminate_connection(mesh, n->connection, false);
-                       /* Run graph algorithm to keep things in sync */
-                       graph(mesh);
                }
        }
 
 
 #include "../src/meshlink.h"
 
 static struct sync_flag bar_responded;
+static struct sync_flag foo_connected;
 static struct sync_flag foo_gone;
 
 static void foo_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
 
        meshlink_set_node_status_cb(mesh, bar_status_cb);
        meshlink_set_channel_receive_cb(mesh, channel, bar_receive_cb);
+       set_sync_flag(&foo_connected, true);
 
        if(data) {
                bar_receive_cb(mesh, channel, data, len);
 
        assert(meshlink_start(mesh));
 
+       assert(wait_sync_flag(&foo_connected, 20));
        assert(wait_sync_flag(&foo_gone, 20));
 
        meshlink_close(mesh);