If your brakes stop working, you should first:

If your brakes stop working, pump the brake pedal several times. This will often build up enough brake pressure to allow you to stop.
DMV Writen Test