Generally speaking, you don't end in the dungeon or wilderness, you end the session when you get back to town. If that means ending the session a little earlier or later than normal, oh well, but its up to the players to manage their time.
There's also plenty of house-rules for things like...