Whenever you're in battle there will be an invisible wall surrounding the area.
If you run into these walls continuously a yellow meter will appear with "ESCAPE" written above it.
If you fill this meter you'll escape so just don't run into the walls and you'll be fine. Keep in mind, though, that some enemies will have attacks that can knock you backwards into the walls and that fills the meter too even if just a tiny bit.