Cleaning up background task logic