Yep, it's entirely based on how many enemies you get so if you get unlucky and the game spawns a bunch of low-number waves you won't be able to get it. There's usually an enemy spawn that signals when you should stop.