diff --git a/src/chat/misc.c b/src/chat/misc.c
index 2eb40c0..a0a646f 100644
--- a/src/chat/misc.c
+++ b/src/chat/misc.c
@@ -156,8 +156,8 @@ void *why2_communicate_thread(void *arg)
 
     //DEALLOCATION
     why2_deallocate(received);
-    remove_node(get_node(connection.connection));
     close(connection.connection);
+    remove_node(get_node(connection.connection));
 
     return NULL;
 }