       @client = false
 
   checkPaths: (paths) ->
-    serverIdx = null
     for path in paths
       dir = atom.project.relativizePath(path)[0]
       @startServer(dir)
+
+  destroyServer: (paths) ->
+    return unless @servers.length
+    serverIdx = undefined
     for i in [0..@servers.length - 1]
       if paths.indexOf(@servers[i].rootPath) is -1
         serverIdx = i
-    if serverIdx
-      server = @servers[serverIdx]
-      client = getClientForProject(server.rootPath)
-      client.unregisterEvents()
-      client = null
-      server.stop()
-      server = null
-      @servers.splice(serverIdx, 1)
-      @setActiveServerAndClient()
+    return if serverIdx is undefined
+    server = @servers[serverIdx]
+    client = @getClientForProject(server.rootPath)
+    client.unregisterEvents()
+    client = null
+    server.stop()
+    server = null
+    @servers.splice(serverIdx, 1)
 
   getServerForProject: (rootPath) ->
     for server in @servers

    @registerHelperCommands()
    @provider.init(this)
    @initServers()

  init: ->
    @setActiveServerAndClient()
    @initialised = true
    @registerEvents()
    @registerCommands()

    return true

  registerEvents: ->
    @disposables.push atom.commands.add 'atom-text-editor', 'tern:references': (event) =>
      if !@reference
        Reference = require './atom-ternjs-reference'
