Top result from Google.
https://jmarshlaw.com/can-you-refuse-to-exit-your-vehicle-when-ordered/Tldr: if police say get out of the car, you get out of the car. Article cites Pennsylvania v Mimms and Maryland v Wilson.
To the street law folk, when it says "lawful" that's decided by a judge, not the citizen. What happens if that if the stop is deemed unlawful (for example, no headlights, but it's clearly daylight and not raining)? Well, then you get to file a civil rights complaint and get paid.
In this instance, breaking the window and ejecting the driver is not going to be a valid civil rights complaint because it is within the cops powers and expected authority.
These powers are generally granted due to the "what if he has a gun" question, whether likely or not, because that's the type of case that usually makes it to SCOTUS.
Yup, stop was questionable at best. Had he complied, it's a $100 no headlight ticket, easily dismissed by him just showing up to court. Assuming "they smelled marijuana" and the stop goes further, a lawyer makes this go away with almost no effort.
One change in the law id really like to see is that attorneys fees and reasonable expenses be covered in clearly incorrect stops like this. That simple fix gives the "but the corrupt cops cost me time and money" side a very solid reason to stop arguing on the roadside and make everyone a ton safer.