If I'm getting an early flight, I tend to stay a day longer, then hang at my resort, have breakfast and then relax for a bit before heading to the bus. If it's a late flight, then I try to get as much time in a park as possible that day. When I left WDW a week or so ago, I had a 6:00pm flight....DME was at about 3pm. I was at BC. I was able to join some friends and see Dr Strange that morning (DVC preopening screening) in DS at 9am, then headed to DHS to spend time with my CM dd. I headed to the Dolphin about 1ish, grabbed lunch at Picabu, then back to BC and my goodbye Mickey Bar!!!
For a 5:15pm flight you will get a pick up time of around 2:15....15 mins either way. You should be out at the bus stop, ready to go, at least 15 mins prior to your p/u time!! That means getting back to your resort no later than 1:30....everyone always likes to make that last sweep of the gift shop, the restrooms and such. Most have carry on bags stored with Bell Services, that can take a bit of time to get them back.