     disposable = pane.onDidChangeActiveItem ->
       activeItem = pane.getActiveItem()
       if activeItem != termView
-        return termView.term.constructor._textarea = null
+        if termView.term
+          termView.term.constructor._textarea = null
+        return
 
       process.nextTick ->
         termView.focus()

      splitter()

  newTerm: (forkPTY=true, rows=30, cols=80, title='tty') ->
    termView = @createTermView {forkPTY, rows, cols}
    pane = atom.workspace.getActivePane()
    model = Terminals.add {
      local: !!forkPTY,

    atom.packages.activatePackage('tree-view').then (treeViewPkg) =>
      node = new ListView()
      treeViewPkg.mainModule.treeView.find(".tree-view-scroller").prepend node
      # @newTerm()

  getTerminals: =>
    Terminals.map (t) ->
