Wait for client to close connection: improvement (I hope)