A day job helps.......or anything/anybody else that will nag you or pressurise you to take your nose out of whatever it is. Though people are generally far too polite about this and even spouses won't necessarily do much to avoid becoming Warcraft widows or whatever.
I often set alarms to remind me that I didn't intend to do my special interests for so long. Usually I can disengage once the alarm has gone off. Not that it's pleasant.
It helps if the final thing I do before stopping is to summarise the info I'll need when I resume....part of the problem with my adherence to the task in hand is that I don't relish the prospect of trying to get back to where I was when I left off.........so I'm more likely to stop if I feel I have a strategy for re-engaging.
When I consider stopping, I try to listen to my excuses for not stopping, and if they don't hold water, I try to override them.
Social activities often take my interest away from the more nerdy things I do. Though I've long felt that social activities are a kind of special interest for me. If so, then the problem isn't really solved unless I can stop socialising when I need to.........no problem there AFAIK. Usually I have to fight an urge to run away and hide anyway, when I'm doing social stuff, and there's also my extreme reluctance to do anything that might come over as invasive.....I feel that the other people are granting me their attention, and I don't wish to wear out my welcome, so I will usually back off if i suspect that they've had enough of me for now.
I guess I could be accused of analysing social encounters too much.......I spend a lot of time doing that....but I suspect it's necessary, to make sense of what I've been through. I can't do it like an NT and just act on all the social ramifications, I have to sit down and work them out the long way.
One thing I twigged, some years before I knew of AS, was that I'd best make sure my hobbies had some kind of useful outcome. I'd noticed that many of my activities had been so narrowly-focussed that I'd completely overlooked easier and much quicker solutions that would have spared me months of isolated, painstaking labour. So these days I always try to ask myself, "Is there an easier way? Realistically, how important is the result? Am I the best one for the job? Could I use my time better?" So I recommend cultivating a mentality that looks at what one is trying to do and why, rather than just taking it for granted that the task is simply to do or die. And frankly some of the goals I set myself are nothing like as important as they seem when I first get the idea. I often have a weird feeling that the idea I'm currently having is the most important one there's ever been, but the truth is that it's all pretty finite stuff.
It can be a tad alarming to question one's special interests in this way.......I think we often love them every bit as much as we'd love a person, so it hurts us to see them as unimportant and to think of leaving them. I feel empty when I've completed a nerdy project, because it's over.
I think it also helps to be aware of whether you're doing the special interest for the result or for the pleasure/relief of the process itself. Often with us it's the latter, though it took me a long time to realise that......I thought I disliked the work itself and only wanted the results, but it's not the work I dislike, it's the feeling of life slipping by while I hide away that I hate. Once you know that you're mainly in it for the catharsis, you can manage it more like you would manage the use of a recreational drug such as alcohol.....most people master that, but an unlucky few become its servant.