SPARK-1656: Fix potential resource leaks

JIRA: https://issues.apache.org/jira/browse/SPARK-1656
On Unix at least that's not necessary. It's possible to delete a file with open fds. The inodes will be released when you close the fd.

Don't know if Windows follows the same semantics, though.