Fix 100% cpu hanging after closing a connection

[#85054926]