Added option to close temp files in optimisation mode.

Issue #58.