For example, imagine Cousin Marty says something like “Kids these days just aren’t going to church. It’s all that rock and roll they’re listening to. Right?” You could follow up with “Speaking of kids, I’ve been meaning to ask: how’s your daughter doing at college?”
Be prepared with a few neutral conversation starters, like “So what did you all think of the last Game of Thrones episode?” or “Anyone have travel plans for the summer?” Whenever you’re around the person who likes to talk about religion, just lead with one of these neutral topics.
You can make the shift suddenly, like “Hey, isn’t that Pam over there? Let’s catch up with her! Hey Pam! Over here!” Try to have a friend or ally be your buffer. They’ll probably pick up on what’s going on and try to help out.
Make up an excuse where the person can’t reasonably follow you. For instance, if you say you’re going to refill your drink, they might try to follow you. Instead, say you’ve got to go call home and check on things.
Something like “Why don’t we talk about this at the next company picnic?” should do the trick.