You need priorities and control tick.
First of all, put a timer on your enemy. This will be the control timer. Every time it runs out, the enemy should decide what to do : run from the player or escape corner. Then you call the corresponding function and start a new timer to choose a new action, but not right now.
What it would do in game :
T=0s : enemy choose to run from player, start new timer (2 seconds ?)
T=2s : enemy is not far from the corner, and the player is close too. The enemy chose to run from the corner, and starts a new timer. He will the run from the corner for at least the timer's duration, meaning it won't do back and forth every millisecond.
When you make AI decisions for anything, having a control timer is usefull to prevent micro-orders. I ran into the same problem with a "pet" simulation, where the pet would eat for less than a second, then start running, then eat again because its priorities were almost the same at that time, and each order changed the current priority in less than a second. If no order can be issued more than once in a while, this problem goes away. It makes the ennemy less reactive to the player's actions though.
Another solution is to have a control timer quite short (1 second ?) but in your decision function (the function that decides what the enemy should do), take into account what the enemy is currently doing. If he is running from the corner right now, maybe the proximity of the player doesn't have the same weight in the decision... It's all try and balance then.