It's self-soothing. You just give him the time and space he needs to get himself back to equilibrium. Let him cry it out until he's done.
And I don't mean you isolate him, or leave him alone. You can sit in the room with him, so he knows you're there and ready to help deal with whatever's wrong as soon he's able to talk about it. If it takes a very long time, you can go do things. But keep an eye on him every few min, make sure he's safe.