It is generally considered rude to tell someone to shut up. Even if you phrase it more politely, they may still take offense as people believe they have the right to speak when they feel like it.
Yet there are certain situations where it is fully justified and could save both your lives. One is when driving.
Passengers can be incredibly distracting to drivers
It is nice to have company in the car, and passengers who like to talk can be crucial to keeping you awake when on a long journey (although stopping and getting rest is a far safer plan). Yet sometimes, the conversation becomes too much, and you need absolute silence so you can focus on the road.
Humans are not very good at doing two things at once
Despite some people claiming to be great at multi-tasking, we are not. At least not when both tasks require brainpower.
You might be able to spin a hula hoop while chewing gum or sing while playing the guitar, but that is because you are not asking the same part of your brain to think about two things at once. When listening to someone, your brain needs to focus and process what they are saying and possibly formulate a reaction. When you drive, you need your brain to process what is happening around you and make fast decisions, especially around junctions or in complex traffic.
The roads are full of drivers who make dangerous decisions that could endanger you. Do not be afraid to cut the conversation if it helps you avoid a car crash.