Here is a grammar you may use:
<grammar mode="dtmf" version="1.0" root="oneToFiveSequence">
<rule id="onetofive">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</one-of>
</rule>
<rule id="oneToFiveSequence" scope="public" >
<one-of>
<item repeat="0-">
<ruleref uri="#onetofive"/>
</item>
</one-of>
</rule>
</grammar>
To stop recognition with digit "6" set a property in your VXML form:
<property name="termchar" value="6" />
In the form while processing "filled" event you will know that the sequence was terminated with "6" so you may append it to data if it needs be.
An equivalent single rule grammar as requested in comments
<grammar mode="dtmf" version="1.0" root="oneToFiveSequence">
<rule id="oneToFiveSequence" scope="public" >
<one-of>
<item repeat="0-">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</one-of>
</item>
</one-of>
</rule>
</grammar>
Both variants are tested with Holly Connects Voice Platform
Here is an app you may use for quick testing.
<?xml version="1.0" encoding="utf-8"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
<property name="inputmodes" value="dtmf"/>
<form id="welcome">
<field name="option">
<property name="termchar" value="6"/>
<grammar mode="dtmf" version="1.0" root="oneToFiveSequence">
<rule id="oneToFiveSequence" scope="public" >
<one-of>
<item repeat="0-">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</one-of>
</item>
</one-of>
</rule>
</grammar>
<prompt>Enter digits</prompt>
<filled>
<log> You entered <value expr="option"/></log>
</filled>
</field>
</form>
</vxml>