I’ve noticed it does this when Pokémon despawn, but a few times now it did this when the Pokémon didn’t despawn. I was right behind my Gastrodon. I didn’t even move. I wasn’t on a cliff. Why?
If you were also being targeted by some other Pokemon that's farther away, that one might end up joining the battle, and you can be kicked out for being too far away from that.
If you move to far away from the Pokemon you're battling it'll cancel the battle and give you that message!