/// <summary>
        /// Decrement API instance count and cleanup if this is the last one.
        /// </summary>
        private void StopAPI()
        {
            if (startCount > 0)
            {
                --startCount;
                if (startCount == 0)
                {
                    MLDevice.Unregister(this.Update);
                    MLDevice.UnregisterOnApplicationPause(this.OnApplicationPause);
                    this.CleanupAPI(true);

                    if (this.perceptionHasStarted)
                    {
                        this.perceptionHandle.Dispose();
                        this.perceptionHasStarted = false;
                    }

                    _instance = null;
                }
            }
        }