I see that you are still working on that topic
https://forum.arduino.cc/t/gradient-using-ultrasonic-sensor/1099820/8?u=ec2021
As @anon56112670 already mentioned "do not divide by zero". And - as a microcontroller has a quick but simple mind - it is the task of the developer to avoid divisions by zero.
So check the variable you use as a divider whether it is zero or not before the division is performed.
In this example it should be quite obvious that if the object does not move you cannot crash into another static object.
If it does not move you can stop measuring distances and forget about crashtimes ...
Unless you want it to react on something coming in its direction (like driving backwards, start a buzzer or inflate the airbag ... ).
ec2021