Fix a race condition when writing the event to the tempfile when the periodic uploader
fixing an issue where the logstash-test file was not deleted