The game ends by agreement of the players. If they don't agree on the result ("those stones are alive!") they must keep playing. Chinese rules are much better at this than Japanese ones especially (IMHO) the old ones with the group tax. There are no ambiguities there. Unfortunately the group tax is unpleasant and Chinese rules are a pain to score manually. Japanese rules are full of flaws but are such a nice shortcut that almost everybody except China use them or some variant of them.
Btw, if any Chinese player is reading this, how do you count the score while playing? Do you count territory and remember the number of captured stones or do you count both stones and territory? Thanks.