The most reliable way to ensure a desired length for an output is to specify `-t X` on the output.

But if you need adaptive limiting of the output duration, use

`ffmpeg -loop 1 -framerate 5 -i 000.png -i 000.wav -c:v libx264 -c:a aac -b:a 192k -shortest -fflags +shortest -max_interleave_delta 500M out.mp4`

The `fflag` is applied deeper in the processing pipeline and should be used in conjunction with the `-shortest` switch. The `max_interleave_delta` with a high value is set to avoid writing packets already queued for output.