“I tried to talk him out of it.”
Your friend told you he was going to shave his head. You told him it was a bad idea, but he did it anyway. Now his girlfriend is angry that he did it. You want to tell her what you said so that she doesn't get angry at you.
I tried to talk him out of it.
When someone is making a bad decision, you might try to "talk them out of" it. This means that you try to convince them not to do it.
I'm quitting, and there's no way you can talk me out of it!
This phrase is not too formal or too casual; you can use it in most situations.