On top of my head: each animation has frame numbers. What about instead of random time, you get a random repeat number and then a random frame number. Then count each animation loop and increase them until they reach your target?
For example: get a random repeat number between 2 and 4. (say you got 4)
Then get a random frame number between 0 and 12 (say you get 8)
also get current repeat global variable.
increase current repeat every time animation plays 8
then have a condition that checks current repeat = randomly got repeat number (for our example it was 4) and if true, stop the animation or do sth else.
I hope I could explain it, English is not my main.