You get into an accident on the highway when another car hits the rear side panel of your car. You see them spin out behind you, though you remain in control of your vehicle.
Forget for a moment whose fault the accident was. Just focus on the next step. How soon do you legally have to pull over?
As a general rule, experts agree that you need to do this "as soon as it is safe." If you can do it immediately, do it. If you can't do so right away without endangering other drivers, just try to come to a controlled stop as soon as possible and find a safe place to get out of the traffic lanes.
Above all else, remember that leaving the scene is illegal and you could get arrested for a "hit-and-run." Even if the other person technically hit you and caused the accident, you still can't leave the scene.
This can sometimes get a bit confusing. What if you think it's not safe to pull over on the road itself and so you drive a bit further and pull into a rest stop? You thought that's what you needed to do to stop safely without endangering yourself or anyone else. The other driver thought you were running from the scene and trying to pull off the highway to avoid talking to law enforcement. Who is right? Have you committed a crime or were you following the law?
If you do get charged with a traffic crime, especially if there is any confusion or miscommunication, make sure you know what legal defense options you have.