Fix memory leak in cleanup task