```python
def shed_tail(text: str, piece: str) -> str:
    """
    Take a closing piece off the end of a text again and again, for as long as the text still closes with it.
    A text that never closes with the piece is given back whole, and a piece holding nothing leaves the text alone.
    """
    if not text or not piece:
        return text

    while text.endswith(piece):
        text = text[:-len(piece)]

    return text
```