Quota checks are carried out via pre or post conditions. The isoverquota(quota_name) function can be used to check whether a quota target has been met, and the endsurvey(quotafull) function can be used to mark the current entry as quota full. The isoverquota function should always be placed after the question the quota refers to.
Respondents can be screened out (based on a specific condition) by using the endsurvey(screenout) function. For example, this can be used to screen out respondents who are less than 18 years old after asking an age question. The following script shows this scenario:
First, we would define Q1 as:
<choice id="1" label="< 18" anchored="false" exclusive="false" always_shown="false" alias=""/>
<choice id="2" label="18" anchored="false" exclusive="false" always_shown="false" alias=""/>
<choice id="3" label="> 18" anchored="false" exclusive="false" always_shown="false" alias=""/>
</question>
We would then add the quota to this question:

Finally, we would define Q2 as:
<precondition if="isoverquota(SQ1)" then="endsurvey(screenout)"/>
<choice id="1" label="Not so often" anchored="false" exclusive="false" always_shown="false" alias=""/>
<choice id="2" label="Once a year" anchored="false" exclusive="false" always_shown="false" alias=""/>
<choice id="3" label="Several times a year" anchored="false" exclusive="false" always_shown="false" alias=""/>
</question>
If the respondent is 18 or less than 18 years old, he/she will be screened out and the survey will end.