What is the meaning of [quit while you are ahead]

Give up doing something when you are in a good position rather than risk what you have already gained