Exit loop as soon as last session is selected

No need to continue any further when the last index is set.