Fix bug detaching on pane close