Work shouldn't be a place where you come to air out your problems. When I'm at work I'm there to work. I don't mind talking about life in general, but work shouldn't be a place to work out all your troubles. I've also told employees before that come to work upset about something outside work to think about work as a safe place.
Here is what I might say, "While at work you can't actually deal with whatever is going on outside of work. And whatever the problem it will be there when you get off work. So for the next few hours while working let that other stuff go and focus on the task at hand. While at work you don't have to stress about things outside work, because you can't do anything about it. So just enjoy this freedom from that trouble for now and put your energy into your work."
Most people have found this helpful.