/// <summary>
        /// Shuts down the context and closes any open devices.
        /// </summary>
        public static void ShutdownContext()
        {
            // Close all devices
            foreach (Kinect device in KinectNative.deviceMap.Values)
            {
                device.Close();
            }

            // Shutdown context
            int result = KinectNative.freenect_shutdown(KinectNative.freenectContext);

            if (result != 0)
            {
                throw new Exception("Could not shutdown freenect context. Error Code:" + result);
            }

            // Dispose pointer
            KinectNative.freenectContext = IntPtr.Zero;
        }