{% for block in entry.matrixField.all() %}
        {% switch block.type %}
            {% case 'blockType1' %}
            <div>
                {{ block.field }}
            </div>
            {% case 'blockType2' %}
            <div>
                {{ block.field }}
            </div>
            {% case 'blockType3' %}
            <ul>
                <li>
                    {{ block.field }}
                </li>
            </ul>
        {% endswitch %}
    {% endfor %}

Now output code within

    <ul>
        <li>blockfield</li>
    </ul>
    <ul>
        <li>blockfield</li>
    </ul>
    <ul>
        <li>blockfield</li>
    </ul>

But I want output like this:

    <ul>
        <li>blockfield</li>
        <li>blockfield</li>
        <li>blockfield</li>
    </ul>

That is, I want 'ul' tag to follow the loop of blocktype3.