Rework tab closing

This changes the way a new tab is selected when the active one is closed. Instead of picking the first inactive slot from the unordered list of slots associated with a pane, the next or previous slot as currently displayed in the corresponding notebook is chosen.