def METHOD_NAME(self, request, ec2_instances, aws_obj):
    def finalizer():
        current_sg = aws_obj.store_security_groups_for_instances(
            self.instances_in_az
        )
        if self.original_sgs != current_sg:
            aws_obj.restore_instances_access(
                self.security_group_id, self.original_sgs
            )
            logger.info(
                f"Access to EC2 instances {self.instances_in_az} has been restored"
            )
        if self.security_group_id in aws_obj.get_all_security_groups():
            logger.info(f"Deleting: {self.security_group_id}")
            aws_obj.delete_security_group(self.security_group_id)
    request.addfinalizer(finalizer)