     item
 
   # Public:
-  removeItem: (item) ->
+  removeItem: (item, destroying) ->
     index = @items.indexOf(item)
-    @removeItemAtIndex(index) if index >= 0
+    @removeItemAtIndex(index, destroying) if index >= 0
 
   # Public: Just remove the item at the given index.
-  removeItemAtIndex: (index) ->
+  removeItemAtIndex: (index, destroying) ->
     item = @items[index]
     @showNextItem() if item is @activeItem and @items.length > 1
-    @suppressBlur => @items.splice(index, 1)
+    @items.splice(index, 1)
+    @suppressBlur => @emit 'item-removed', item, index, destroying
+    @destroy() if @items.length is 0
 
   # Public: Moves the given item to a the new index.
   moveItem: (item, newIndex) ->

      .map((activePane) => activePane is this)
      .distinctUntilChanged()

  destroyingItem: false

  constructor: (params) ->
    super


    @emit 'before-item-destroyed', item
    if @promptToSaveItem(item)
      @emit 'item-destroyed', item
      @removeItem(item, true)
      item.destroy?()
      true
    else
