You can start the cleanups by splitting long-running jobs into batches and writing the intermediate results to disc.