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.