Myself, I tend to ask with open question, a good ice breaker is: "Hey mate, hows your day going on a scale of 1-10?"
That gives them a chance to take a break and think. If they say three, you put yourself in their shoes. "Hey, that sucks. what's going on?" just lending a warm comforting subtle "I'm around right now if you want to talk"
If they give you a higher number, inquire why. "Wow, a 7? That's great. How come?" Both results in giving them option to speak. You compliment in both situations, a win win. If they return with a single closing statement acknowledge it and move on, "all the best".
If you need to end, a simple of "hey, it was great talking. I've got my coffee it was a pleasure talking to you while I waited, I've got to take off but it was a pleasure to talk".
You cater it to the situation you're in. If they want to talk then they will, if they don't then they won't.