When running gst-launch-1.0, it does not properly force an EOS on the bus before shutting down. Since the MP4 container requires an index (the MOOV atom, see:
http://www.adobe.com/devnet/video/articles/mp4_movie_atom.html) and mp4mux only writes this index after receiving an EOS, you will write an invalid mp4 to disk when no EOS is detected. You can fix this by adding -e to your command line, e.g.:
gst-launch-1.0 -e -v autovideosrc ! queue ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink location=test.mp4 sync=false
This will send an EOS on the pipeline just before shutting down.