Fix resource leak when offline file download