The reason it's repeating your subroutine is because that's all that's left for it to do after it exits the loop. DB is a little different than languages like VB, where a sub is never run until it is called. DB looks at code line by line, so when it exits the loop, it just goes onto the next line which is your sub. Then at the end of your sub, it doesn't have anywhere to return to, so it ends.
What you need to do is change your exit to "end." Or if you want a fancy ending sequence, send it to a separate subroutine.
Hopefully that makes a little sense.