public void OnApplicationQuit() { // if somehow this method is not called, the discovery thread will not be stopped instance.stopDiscovery (); }