It is provided in step 7.
The way this is robot is designed, it is not possible for the robot to move sideways.Thanks for the comment!
I did it by disconnecting the power. You can add a switch between the power source and the robot. Another way to do this would be to add a variable to the code whose value increases with each loop so that it turns off after completing a certain number of loops.