app: disallow a theoretical infinite loop if we run out of ids.

In practice, that's likely impossible to ever happen. This was just
itching my perfectionist self, who enjoys flawless design.