When you turn off the engine, you lose power assist for your steering and brakes. This means that it will be much harder to steer and stop the car, which could lead to an accident.
In addition, turning off the engine in drive can damage the transmission
Always shift the car into "park" before turning off the engine.