Check for nil before calling close
Merge branch 'fileleak' into fastmove