Added code to close open file handles that might be possible open.