Close resource leak in temporary file manager.

Note that the class has associated unit tests which may assist in testing this PR.