     @handles.splice index, 1
 
     if shouldDetach
+      @panes   = @panes.filter   (p)-> p isnt pane
+      @handles = @handles.filter (h)-> h isnt handle
       pane.detach()
       handle.detach()
     else

      @handleClicked index, event

  # DEFAULT ACTIONS
  handleClicked:(index,event)->
    pane = @getPaneByIndex index
    if $(event.target).hasClass "close-tab"
      @blockTabHandleResize = yes
      @removePane pane
      return no
    @showPane pane

  # DEFINE CUSTOM or DEFAULT tabHandleContainer

        view       : tabHandleView
        closable   : closable
        sortable   : sortable
        click      : (event) => @handleClicked event, newTabHandle

      @addHandle newTabHandle

