Summary:
Previous approach was a bit flawed as the `isOpen()` API returns true by the time close is called.
This was OK in the case of errors, as the open flag was set to false hence preventing us to report a close after the error. It is not OK on healthy disconnect situations as these events were not getting reported.
In this case, a better solution is just to clear the event handler after a close or error because in either case we are no longer interested in dispatching any other events to the handler.
Reviewed By: antonk52
Differential Revision: D47510883
fbshipit-source-id: 883a3f87f24f71fe44a624590a310fe2563cbd8a