     @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'

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

      closeAppWhenAllTabsClosed : no

    @tabView
      .on('TabsSorted',    @bound 'updateSessions')
      .on('PaneDidShow',   @bound 'handlePaneShown')

