If your engine stops suddenly while driving, the first thing you should do is:
Brake the vehicle to a stop.
This is important to safely control the vehicle and bring it to a stop. Once the vehicle is stopped, you can then assess the situation and take further actions as necessary.