code: def exit(self, timeperiods, hosts, services):
          
          if self.ref in hosts:
              item = hosts[self.ref]
          else:
              item = services[self.ref]
  
          broks = []
          # If not is_in_effect means that ot was probably a flexible downtime which was
          # not triggered. In this case, nothing special to do...
          if self.is_in_effect is True:
              # This was a fixed or a flexible+triggered downtime
              self.is_in_effect = False
              item.scheduled_downtime_depth -= 1
              if item.scheduled_downtime_depth == 0:
                  item.raise_exit_downtime_log_entry()
                  notification_period = timeperiods[item.notification_period]
                  # Notification author data
                  # todo: note that alias and name are not implemented yet
                  author_data = {
                      'author': self.author, 'author_name': u'Not available',
                      'author_alias': u'Not available', 'author_comment': self.comment
                  }
                  item.create_notifications(u'DOWNTIMEEND', notification_period, hosts, services,
                                            author_data=author_data)
                  item.in_scheduled_downtime = False
                  if self.ref in hosts:
                      broks.append(self.get_expire_brok(item.get_name()))
                  else:
                      broks.append(self.get_expire_brok(item.host_name, item.get_name()))
  
          item.del_comment(self.comment_id)
          self.can_be_deleted = True
  
          # when a downtime ends and the concerned item was a problem
          # a notification should be sent with the next critical check
  
          # So we should set a flag here which informs the consume_result function
          # to send a notification
          item.in_scheduled_downtime_during_last_check = True
          return broks
docs: Remove ref in scheduled downtime and raise downtime log entry (exit)
  
          :param hosts: hosts objects to get item ref
          :type hosts: alignak.objects.host.Hosts
          :param services: services objects to get item ref
          :type services: alignak.objects.service.Services
          :return: [], always | None
          :rtype: list