For example, if one had a stone smash car glass while driving in a dangerous place, but was not hit himself?
There is a blessing just for that, called
Its a bit hard to translate to English, but something like
the blessing of the one who is in charge of Rewarding for good and evil.
It thanks god, who is in charge of rewarding for good and bad, who is rewarding me for the good.
I encountered some changes for the actual text for different Jewish streams, but all say the same.
You can read Here