Close created file after opening for upload

This fixes a possible memory or file descriptor leak, in any case.