improved the code about that still fire Closed event even if the connection failed when it is connecting