Centralize resource deallocation for encmain.

- CppCheck was complaining about unreleased resources for FILE*. They weren't
  really because they get flushed and closed when program exits normally, but
  let's close them anyway.