function to handle client disconnect