You can stop coroutines by using "yield break" or just letting the method reach the end of the code (as long as you've yielded at some point in the method). In the example in the other post it spawns 10 entities then the routine ends