It was fun trying to eat $25 worth of desserts!!
We generally try to leave a Disney park around 12:30pm, so we do our last ride at 12 noon and wander out. Then we get gas, stop at McDonald's for food to eat at the station. It takes about 40 minutes to get from WDW to Sanford. So we are usually there about 1:30pm to check into Amtrak (2pm was the latest when we ran into traffic).
We have always gotten the early dinner service when we wanted it so this must be a good time. However, the station is generally more than 1/2 full at this time so some people get there a lot earlier than us!!
I would definitely aim to get there before 2pm if you are dead set on the 5pm service. Better, if you can do 1:30pm, if you know the train is full (you can go on-line and try to make a room reservation. If you are denied, then you know the train is full).
If for some reason, the 5pm is is already full, you can always ask your Sleeping Car server to bring the food back to your room for you. Of course, be prepared to tip him/her for that (but you have to tip the waiters in the dining room too, so it's not much different).
If you are doing coach, I think you can ask your server to do the same, but I'm not sure on that.
So yes, you can still spend some time in the parks or at DTD or your resort on the day you depart.
HTH!