     @on 'VMItemClicked',     @bound 'prepareAndRunTerminal'
     @on 'PlusHandleClicked', @bound 'handlePlusClick'
     @on 'WebTermConnected',  @bound 'updateSessions'
+    @on 'TerminalClosed',    @bound 'removeSession'
 
     {vmController} = KD.singletons
     vmController.on 'vm.progress.error', => notify cssClass : 'error'

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

  addStartTab:->


      storage.setValue 'savedSessions', sessions
      storage.setValue 'activeIndex', activeIndex

  removeSession: ({vmName, sessionId}) ->
    @updateSessions()
    {vmController:{terminalKites}} = KD.singletons
    terminalKites[vmName].webtermKillSession
      session: sessionId
    .then (response) ->
      log 'session removed from terminal kite'
    .catch (err) ->
      warn err

  addNewTab: (vm) ->

    KD.mixpanel "Open new Webterm tab, success"  if @_secondTab
