single cleanup function for downloading