How to drive motors and use an ultrasonic sensor simultaneously?
For the first question, you could simply implement an interrupt routine to regularly check the status of your sensor and when it achieves the desired threshold it triggers the action to stop the motor. 

You can achieve this by setting timer1. There is a library here for example, where you set the period to execute a desired function, when some distance is detected you just stop the motors.

The second question could be done exactly like you said. Say you have some paths saved in memory, you can just create some options for them and execute whenever you want using switch/case command.

http://playground.arduino.cc/code/timer1