There are two reliable ways out of a dungeon. The first is simply to find the exit you came in by, whether that is a ladder, a rope, a cave mouth or a staircase.
The second is to teleport. A teleport spell, a teleport item or a lodestone network option will pull you out instantly, which is usually faster if you are low on health and not in the mood to retrace your steps.