Some methods:
* Cast a levitate spell (or use an Ali's Carpet), then go up through the portal you used to enter the floor; this is the method that you most likely have access to that isn't inconvenient. (This takes you back to level 3.)
* Cast Apport Arcane, if you know the spell. Level 4 is no teleport, but the game only checks the destination level, so you can easily warp back to a safer area. This is my preferred method if it's available. (That spell is quite handy; if you are playing the remaster without automapping diabled, you can cast the spell from the automap and click where you want to teleport; if not, there's SCSI.)
* Cast Safety Spell (if you're playing the remaster without Misc. Game Differences). This will warp you out, but you will lose all your money, so it might not be the best option. Apport Arcane is definitely preferable if it's an option.
* Deathwarp. To do this, simply let your entire party die. The Brilhasti fight, if you are able to reach it, is probably your best option; if you are having trouble losing the fight, you are probably ready to kill Brilhasty and probably don't need to ask this question in the first place. (Remember that you can Party attack during battle to speed things up.) The downside is that your party will be dead, and you will need to go to the temple to revive everyone (unless you have Beyond Death, in which case you only need to revive your Wizard or Archmage); I believe this costs 900 per character level for each character to be revived. Depending on how much money you have, this may or may not be preferable to casting Safety Spell (or you might not have either that spell or Apport Arcane in the first place). (Also, note that you ideally don't want any characters to be turned to stone, as it costs extra to cure that if you don't have someone with Stone to Flesh, in which case you probably have Apport Arcane and possibly Safety Spell.)