Dungeons must be completed to get full credit. Logging out, leaving through the Dungeon entrance, going to another dungeon, playing a Mini-game, going to a PvP or Derby match, or going to your home will reset the Dungeon. Leaving any other way gives you 30 minutes to return before the Dungeon resets.
To make it clear: You can play games at the Fairegrounds (and probably other places that offer the potion-filling games) to refill potion bottles and still re-enter your dungeon as it was when you left. I just tried it by teleporting out of Nightside. playing a game, and reentering.
I killed everyone but I still can't leave the dungeon. Why? There doesn't appear to be anything else to do in it.
Why can't you leave the dungeon? Which one are you talking about?
Some of the dungeons have a "warning" that appears when you try to walk out of the dungeon. It says something about "are you sure you want to leave? You will lose all progress...".
But if you defeated everything you were supposed to do, then it is okay to walk out of the dungeon. Hope this helps.