There is a youtube channel called Active Self Protection and they review security and badge cam shootings and point out the good and the bad.
One thing they talk about is be aware of your surroundings always, including walking to and getting into your car. Don’t fumble with keys. Get in the car, lock the doors, start it, put it in gear, then seatbelt and leave. Don’t look at your phone, etc.
...
I suggest the first thing is to open the door and immediately lock the doors BEFORE getting in. This way the car is secure right away. This has now become second nature.
It happened to me.
I was aware of a guy approaching my car and as I opened the door the footsteps increased to a run.
Opened the door, locked the doors, got in quickly and slammed the door behind me. As the door slammed closed, his hands were on the latch, violently pulling to try to open it and began punching the window. I pulled out a EDC, just waiting for the glass to break, which it didn't. He saw the EDC, jumped back, yelling and ran away.
It was that fraction of a second of a difference that secured me that night.
So, experience has taught me
Open the door
IMMEDIATELY lock the doors and QUICKLY pull the door shut.
It will buy you a bit of time and may save your life.
...that is all