When to quit

First of all I am notoriously bad at knowing when to quit. I keep trying things thinking I’m almost there and that I’ll get that code working in the next 5 minutes. Then 3 hours later I have a huge mess and it’s not done yet with me scratching my...