On the beach we think about 3 factors: Light, onshore and gnarly surf. Pick any 2 and you should be right, but get all 3 and you don't have a chance.
If in doubt sometimes it's better to body drag all the way out the back - sometimes that's all that you can do.
Otherwise practice quick gybes, try to find a rip or deeper patch of blue water where there's no break. Look at the sweep and body drag angle and aim to get to that deeper patch then more or less zigzag as required to avoid the breaking sections till you're past it.
If all fails and you're taking on the whitewater then see tips above