means that
it can be wise to stop while one is successful rather than risking existing gains by continuing unnecessarily.
The saying “Quit while you are ahead,” can be used when it is better to give up doing something when you are in a good position, especially when further action runs the risk of spoiling or reversing….