       }
 
     $scope.refreshStats = (id) ->
-      return unless (get id)?.power_state is 'Running'
+      if (get id)?.power_state isnt 'Running'
+        refreshControl.cancel()
+        return
+
       return xo.vm.refreshStats id
+
         .then (result) ->
           result.cpuSeries = []
           result.cpus.forEach (v,k) ->


        prepareDiskData mountedIso

        # get the RRDs every 5 sec
        interval = $interval(
          () => $scope.refreshStats(VM.UUID)
          5000
        )
        $scope.$on('$destroy', () => $interval.cancel(interval))
    )

    descriptor = (obj) ->

            result.xvdSeries.push String.fromCharCode(Math.floor(k/2) + 97, ) + ' ' + if k % 2 then 'write' else 'read'
            return
          result.date.forEach (v,k) ->
            result.date[k] = new Date(v*1000).toLocaleTimeString()
          $scope.stats = result

        .catch (err) ->
          refreshControl.next()
          throw err

    $scope.startVM = (id) ->
      xo.vm.start id
