How to avoid arguments

Yesterday I was talking with a Christian friend of mine, and he seemed determined to argue with me about religion. I'll admit, I probably should've walked away sooner, but I couldn't help get sucked in by just how badly he was misuderstanding evolution, the Big Bang and whatnot. It was infuriating how dumb he thought I was for not believing in God. Does anyone have any things to say, mantras to think, or other ways to avoid arguments? I love a good discussion every now and then, but this guy was not looking for that.