public static void StopInstance(Instance instance)
        {
            if (instance.ApplicationPoolState == ObjectState.Started)
              {
            instance.StopApplicationPool();
              }

              // Sleep for max 60 seconds until it's really stopped
              for (var i = 0; i < 60; i++)
              {
            if (instance.ApplicationPoolState != ObjectState.Stopped)
            {
              Thread.Sleep(1000);
            }
            else
            {
              return;
            }
              }

              throw new ApplicationException("Instance not stopped within 60 seconds");
        }