close socket when background process is started