Hey there @fred29
This is a very good question, but also a tricky one to try to answer TBH
I think there are 2 main different sides of production that need to be taken into account. One is the creative process and the other is the technical aspect.
Next to those 2 different aspects of producing music, most people will agree on the fact that the less time you spend on one project, the better it is, but then comes back the question : when do you know it's finished ?
So, maybe instead of trying to answer this tricky one, it's better to try to understand what can really help to finish tracks & projects.
On the creative side of things, I think that laying down ideas should be something separated from starting a track from scratch with a real goal in mind. The same can be applied to the technical aspect, experimenting & trying out new techniques should be something different than using proven to work techniques to achieve a desired result.
Firing up your DAW on a blank & empty canvas without a rather clear picture of what you gonna create can often be counterproductive IMO. It leads to multiple things to do and a potential endless list of choices & next moves to make. Creativity isn't granted everyday, it comes and go, depending of many things like the mood we're in, the physical & mental state and many other little factors than we're not even always aware of. So spending too much time staring at a blank template and have to go to all things like finding a nice beat or melody to start with, choosing the right sounds to use, developing a song structure and build around it, mixing parts together... can quickly generate ear & visual fatigue that will alter your decisions & listening dispositions overtime. Let's say that you write a simple 4x4 kick pattern and bass and then you spend a certain amount of time switching kicks to get the right one and listening to just this in a loop : then your ears & mind are gonna get quickly tired of it.
On the other hand, starting a project with a rather clear goal and picture of what the track should be can really make things much more easier. Unless you're writing experimental music, it often comes to establish things like the genre of the track and the final purpose of it. What genre it is ? For which audience and listening context ? Is it a track made to be listened in the comfy of your home ? Is it a gym workout or sport motivating track ? Is it a club track ? Should it be DJs friendly ? ...etc.
So it all start with : what am I gonna produce today ? Once you've define the genre and the audience, it's more easy to break down things like BPM, core sounds to use that make this genre, song structure & arrangement.
From there it's definitely a very good habit to pickup reference tracks that you like and work in this genre. Referencing is not about copying someone else's track or style, it's more about deconstructing tracks that work & trying to get the core elements that make them work well. It can be fundamentals sounds that you can't do without according to a specific genre, typical scales being used for this kind of music, structure build up and song progression, full track arrangement but based more on the listener or eventually DJ approach rather than the creator's mind set.
Once you've defined this, it's more a matter of answering questions and going through a check list, for both the creative & technical aspects of the production. Does the song fills it's purpose for the audience ? Is it appealing or entertaining enough ? What could be missing ? Does adding this new elements really enhance the track ? And then a more specific checklist on the mixing process : am I done with each parts like drums, bass, melody, vocals, fx & ear candies ? Does all part sounds good ? Does the all mix matches reference tracks criteria like levels, clarity, loudness, dynamic...etc.
If you feel like you've answered all those questions and been through all the technical processes that could make the track sounds good and are happy with the result, then you're probably done with the track. Passing a certain point of production, there should be no need & point to add extra processing or new elements unless you're sure it will benefit the track and it was missing.
At a much earlier stage of any project, if it doesn't work out and you feel like you're getting nowhere and struggle to develop the track, then it might be wise to either ditch the project to the bin or save it in an "ideas" folder and start a new project.
Then comes the time where this very own piece of music that you're happy with needs to be heard, needs to be tested by other listeners than yourself. There's a very tricky area in producing music, especially when you do it alone as opposed to collaboration with someone else or making music in a band. We often get absorbed by a great synth pad, a melody, great arpeggios sequences or a killer bass line only to find out that it was all very subjective because we've been in the creative process and enjoying the music we've made. So again, staying critical and using references tracks to judge our work is a first step, then it's probably a good habit to share the results with others, make them listen to your music and be open minded to critics & suggestions from others, despite the fact we've spend days, weeks to craft a track and be happy with the result.
So again, there's no simple & straight forward answer to your question as to know when to put a project aside or simply decide to ditch it and start a new one, but I think it's important to keep in mind what music production really is. Even in electronic music, each track should fulfill a purpose, and having a clearer goal in mind that just starting with nice musical ideas can really help to decide if a project is developing well or if it's leading nowhere & time to stop.
Some people find it more easy to work with templates, that can be good if you're producing in one specific genre or if you have developed your own signature sounds overtime and it can speed up both creative & technical aspects of the production, but still you have to know where you're going after a certain amount of time, sometime it will be the music itself that leads you to the next move, but it's also a tricky part since we're then more into subjective creation territory than objective production.
Hope this could help & sorry for the long writing but no simple answer to that one