Use av_exit() instead of exit() for a minimal cleanup