If you’ve even been pulled over, you know the anxiety that seeing those flashing lights behind you triggers.

Such moments are also stressful for the police officers.

“From the outset, we have a job to do,” says Sgt. Jeff Carlisle, academy supervisor of enforcement tactics at the California Highway Patrol. “We have a mission to provide for the safety and security of the motoring public. We also recognize that making a traffic stop is one of the most dangerous jobs a patrol officer has.”

Safebee spoke to the CHP and New York State Police about what people should — and shouldn’t — do when they are stopped and questioned.

Related:  What to Do (and Not Do) if You're Home During a Robbery

What you should do if you’re pulled over

The first thing to do when an officer pulls you over is signal and carefully come to a stop on the right side of the roadway, as far to the shoulder as possible, says Trooper Ronald Cardis Jr. of the New York State Police.

“In most cases, the officer will pull you over in an area he has deemed relatively safe,” Cardis explains. “Don’t drive for miles to look for a better spot.”

Cardis recommends shutting off the vehicle and fully rolling down the windows (especially if they’re tinted). Turn off the car and, if you’re pulled over at night, turn on the vehicle’s interior lights so the officer can see clearly inside as he approaches. Then put your hands on the steering wheel. These actions allow an approaching officer to assess the situation and see you’re unarmed.

Never reach for your registration, insurance card or wallet until instructed to do so. Reaching under the seat or into the glove compartment or center console might make an officer think you’re going for a weapon

How to handle the traffic stop

Remain courteous and respectful, police say. Don’t be rude, confrontational or belligerent. This can ramp up tensions.

Carlisle says the officer may appear abrupt but he’s most likely attempting to keep the stop under control. The officer must remain vigilant of the occupants of the car as well as traffic passing at sometimes high speeds.

Remember to speak loudly enough for the officer to hear you above traffic noise outside the vehicle.

In most traffic stops, the experience usually ends in one of three ways: the officer lets you go, you get a verbal warning or you get a citation. If a crime has been committed, it may end in a summons to court or an arrest.

Remember, never make any physical moves that could be a sign of aggression, police say. Making angry gestures or getting out of the car to confront the police officer face to face can put the officer on the defensive and end in an arrest. If you think you were unfairly cited, dispute it in court. Don’t get into a verbal confrontation with the officer.

At the end of the stop, the officer may direct you on the safest way to pull back into traffic. Listen closely, Carlisle says, to avoid getting into an accident.

Related: When You Should — and Shouldn’t — Call 911

Know your rights

Safety is only half of the equation, says former Los Angeles prosecutor-turned-defense- attorney Anthony J. Falangetti. Falangetti was rated among the top 14 criminal defense attorneys by Newsweek in 2014 and is co-author of the book “A Cup of Coffee with the 10 Best Criminal Lawyers in the Country.”

People should understand their rights and not incriminate themselves when interacting with an officer , he notes.

While it is important to be polite and respectful and put officers at ease, remember that you have Constitutionally protected rights under the Fifth Amendment. You should never lie to a police officer, but don’t hesitate to invoke your right to keep silent, says Falangetti.

Police officers ask seemingly innocuous questions that can be a form of interrogation, he says. Your answers to questions about where you’ve been, whether you’ve had anything to drink and where you’re heading can be used against you in court. If an officer asks you why you think you were pulled over, admitting you “might have been going too fast” is something that could make it into his report and negate your chances of disputing a traffic ticket. Once you admit you’ve had even one drink, an officer can order you out of the car for a sobriety check.

“Remember, you have the right to remain silent and it can’t be used against you,” he said. “You can elect to say directly to the officer, in a very polite way, that you are going to remain silent.”

Unless police see contraband or believe a crime may be in progress — which gives them “probable cause” to search you or your vehicle — police can do so only with your permission or with a search warrant obtained through court, says Falangetti. If a police officer asks for your permission to search you or your car, it usually means he doesn’t have probable cause — so respectfully decline, Falangetti recommends.

If at any point you don’t want to answer questions, even during a traffic stop, tell the officer you don’t want to answer any questions without an attorney present.

“Once you give your consent, anything he finds in that car is fair game because you’ve given up your Constitutional rights,” Falangetti said. “The Constitution defends our rights. That brilliant document protects our liberties from intrusion. Never give that away.”

Related: What to Do if You’re the Victim of Road Rage

Ronald Agrella is a freelance writer and former editor of The Boston Globe’s Boston.com.