Avoid possible crash on disconnect