Fix bug with events being called after disconnect.