Bug fix when closing a pane