xsl:for-each is not a loop, therefore you cannot exit from it. It's a mapping operator, which applies the instructions in the body of the for-each to each node selected by the select expression, and you should think of it processing all the nodes in parallel.
If you want the equivalent of a loop, use a recursive function or template: process the first item in the sequence, then call yourself recursively to process the next item in the sequence, terminating when your condition is true or when the end of the sequence is reached.
Your code looks very odd. The conditions you are testing depend only on variables declared outside the for-each, so if they are true for one node then they are true for every node. And the only processing you do is to bind some variables, which are inaccessible outside the for-each.
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference