There are several, but the general one is when you can no longer keep playing. This is because you are out of playable cards in hand and can't draw: there are no cards to draw, or you are out of gold, or your hand is full, and your hand is either empty or all the cards in it are unplayable (because there are no eligible tiles).