Fixes the selected tab bug when the close button is closed