Perhaps there is no right time.
It’s easy to quit in the early stages but gets harder over time. After 3 years once you’ve invested time effort and energy quitting, even if it’s for the best feels like giving up.
And so, it’s hard to know the right time to quit. If you’ve been working on something for a while and that could just be a few months (it depends on how much you’re putting into it), if you’re thinking of quitting don’t make what you’ve put into it so far be the only reason to keep going.
But some questions to ask and things to consider are:
Do you still believe in what you’re doing?
If you knew what you now know, would you still start today?
Are you doing this for yourself or because you feel you have something to prove?
Do you enjoy doing the work?
Will the end result bring you joy?