close open files, and move dictionary to top