         socket.on "data", (chunk) =>
             @parse_chunk(chunk)
         socket.on "close", =>
-            @alive = false
-            console.log "[ratom] connection lost!"
-            status-message.display "Connection lost!", 5000
+            if @alive
+                @alive = false
+                console.log "[ratom] connection lost!"
+                status-message.display "Connection lost!", 5000
 
     parse_chunk: (chunk) ->
         if chunk

        @server.on 'listening', (e) =>
            @server_is_running = true
            console.log "[ratom] listening on port #{port}"
        @server.on 'error', (e) =>
            if not quiet
                status-message.display "Unable to start server", 2000


    close: ->
        @nconn -= 1
        if @alive and @nconn == 0
            @alive = false
            @send "close"
            @send ""
            @socket.end()
