When they get enough money to accomplish the goal, or accomplish it without having to get all the money, you've got two options: (1) retire to safety/despair after accomplishing goal, or (2) choose a new goal.

Your character can also choose to abandon the goal for a reason your character articulates or that is obvious from the fiction.

When you accomplish or abandon your goal, you have won D&D with that character.