You could create an invisible object on each wall (1-pixel bigger than the wall on the side of the enemies ) that , on collision with enemy while they are running away from the player , set the enemies platform disabled , and the wall width is set to wall width + enemy width , and when the player is far enough , set the wall to it's initial width and set the enemies platform enabled
I hope this give you an idea !