cleanup memory even without threads