Is there a way to use something like foreach without it stopping you from stopping

I am making a 2d tower defence game

I am trying to make it so the enemy always attacks and I am wondering if their is something like foreach but it stops me from stopping the game.

Does anyone have any ideas ?