Fixed the exception on disconnect