Set onDisconnect during instance creation