Fix tab removal bugs

Fixed issues with focusing the next/previous tab upon closing a tab.