Explicitly close file via context manager in PutObject

Fixes test fails on windows.