Close() temp files before renaming them.

Fixes syncing dirty wallet files on Windows.