There are so many terms. Whatever term you choose probably indicates more about your opinion of his behavior than his behavior itself. It would help to know if you think that his withdrawal seems normal and reasonable given the circumstances. Does it appear to be a short-term change in behavior or do you think it is a more permanent change? Is he irritable as well as withdrawn, or does he seem depressed?
I can think of a dozen terms but each one has a different emphasis.
My friend needs time for himself as he's going through his divorce.
I think he will get back in shape very soon. It's just a matter of time.
He's not depressed but he's thinking a lot about his relationship with his ex-wife. He needs to recharge his batteries.
Maybe, there is no such word or phrase to describe his behaviour.
Can I say that he keeps himself to himself for now?
One phrase used in American English is "he's licking his wounds". I've always found it to be a little insensitive but it does give the impression that he is healing and will recover. It also implies that, like an animal, he doesn't want to be disturbed while he is tending to his injuries.
"He keeps himself to himself for now" is certainly understandable and sounds normal to me, although it sounds more like British English than American English to my ear. I think it would be more common in AE to say "He's keeping to himself these days" or "he keeps to himself these days." In casual conversation you might hear "He needs some time to get over his wife/relationship."
There are many, many phrases. I'm sure that other people will have some excellent suggestions.
To borrow from JamesM's zoomorphic allusions you could also say, somewhat lightheartedly, 'he is hibernating'. Or in a more neutral in register, 'he is lying low', also used in reference to criminals but still can be applied.