Sometimes you’re able to grav jump away during combat, and other times if you try you’ll get a message saying “you cannot grav jump during combat” and it won’t let you.
Grav Jumping In Combat
You have to make sure you are trying to Grav Jump, not trying to Fast Travel. You can’t Fast Travel during combat.
In combat – have energy on your grav drive – press F (Scanner mode) target a distant planet with E and then jump. Remember: Fast travel doesnt work.
In other words
You need to fast travel to another system that is not a specific location on a planet cuz then you just jump there but not actually “fast travel”. It’s a little iffy at first but once you realize how it works you can escape any fight if you wanted to.