Avoid crashes on disconnect