Once at end of array, do nothing. Return does not work.

Hello, I have a script at which the end of an array, I want it to do nothing. Return; does not work. Instead, I get an error that the index is out of bounds. Since I do not want it to go back to 0, I want it to stop. Even making the array variable null doesn’t work.

if ( RelativeWaypointPosition.magnitude < 8 ) {
		currentWaypoint ++;		
		//if ( currentWaypoint > waypoints.length ) {
		if(currentWaypoint < 0 || currentWaypoint >= waypoints.length){
			return;
			yield WaitForSeconds(0.5);
			waypointContainer = null;
			Navigate = false;
			inputSteer = 0;
			FrontLeftWheel.steerAngle = FrontRightWheel.steerAngle = 0;
		}
	}

Post the code in which the array goes out of bounds.

FYI the last item in an array has index array.length-1