Close the audio codec before closing the format context

Closes #127.