Hi Gaurav,
As others have stated, I don't think there is an effective way you can exit a for loop. If it was possible to pass dimension member arrays as a parameter to a Global Script Function (which unfortunately is currently not supported) then you could have achieved the desired result with a recursive global script function that exits with a return statement when a zero headcount is found.
Regards,
Mustafa.