No stopping point?

how do we stop the code. with the recurssive function having i+1, if it is equal to n it will return nothing but it will still check the next and next i’s which are not valid. how does that work