When closing serialize immediately instead of in background task