 
     if terminalView.terminal?.server?
     then runner()
-    else terminalView.once 'WebTermConnected', runner
+    else
+      terminalView.once "TerminalClosed", @bound "removeSession"
+      terminalView.once 'WebTermConnected', runner
 
   handleQuery:(query)->
 

    @appendTerminalTab terminalView
    terminalView.connectToTerminal()
    @forwardEvent terminalView, "WebTermConnected"

  addStartTab:->


    pane = @tabView.getActivePane()
    {terminalView} = pane.getOptions()
    terminalView.terminal?.scrollToBottom()
    terminalView.once "TerminalClosed", @bound "removeSession"
    terminalView.once 'WebTermConnected', (remote)=>
      @emit "WebTermConnected"
      if query.command
