clean up logic for backgrounded processes