DC motors (and in particular the ones from that 4WD chassis in the photo) generate a LOT of brush noise that feeds back into the system. Sometimes it is bad enough to cause the Arduino to reset. In your case it sounds like it may be interfering with your ping sensor.
Look down near the end of the FAQ for a solution: http://learn.adafruit.com/adafruit-motor-shield/faq
Your kit may have come with 1 capacitor per motor, but based on the feedback we have been getting, most need the full 3 capacitor treatment.