fixed infinite loop if client does not disconnect properly