i want from the if loop once a value is detected to end the loop
That's what return does. Add a return statement to the if block.
On the other hand, look at what code the return statement will skip, and ask yourself why you need to skip that. It would probably be a lot easier to see the answers if you properly indented your code (and used appropriate amounts of white space). The Tools + Auto Format menu will make the first part easy.