Use ffmpeg_exit() on exit, to clean up.
Also: do NOT use exit() in JNI!