Update selected index after removing UIs that have gone away, so if the selected UI goes away we select the first UI.