You concept appears sound but you’ll want to look at the various ultrasound sensors and make sure the update rate and min detection distance are suitable. You may want to “track” the distance to the wall before you get to your braking point so that you don’t miss it between readings.
Motor controllers will often have a “brake” function that works by removing the power and shorting the motor terminals together.