 
     item = pane.addItem termView
     pane.activateItem item
+    subscriptions.add pane.onWillRemoveItem (itemRemoved, index) ->
+      if itemRemoved.item == item
+        item.destroy()
+        Terminals.remove id
+        subscriptions.dispose()
     termView
 
   pipeTerm: (action) ->

    id = model.id
    termView.id = id

    termView.onExit () ->
      Terminals.remove id
      disposable.dispose()

    termView.onDidChangeTitle () ->
      if forkPTY
        model.title = termView.getTitle()
      else

Terminals = require './lib/terminal-model'
{Emitter}  = require 'event-kit'
keypather  = do require 'keypather'
{CompositeDisposable} = require 'event-kit'

capitalize = (str)-> str[0].toUpperCase() + str[1..].toLowerCase()

