Essentially you're asking for the same thing. If you're constantly overthinking it's become involuntary.

Part of that cycle comes from stress hormones. One of the easiest ways we can motivate ourselves is to increase stress, we do that easily because one of the easy things for our conscious mind is to imagine or remember things, and if we imagine things that make us nervous, we can trigger a release of stress hormones which agitate us and push us to avoid some negative consequence.

For instance, if you have a paper to write, and you lack motivation to do it, you can imagine the result of not doing it, and that will make you anxious, and that anxiety will prompt you to seek out a way to avoid that uncomfortable feeling, which might be writing the paper to get it out of the way, or it might be flipping on the TV so you can crowd out your imagined fear of failure, and console yourself with the promise that you'll get it done later just fine if you rest.

Coffee helps you focus because it lets the stress hormones in your brain persist for longer, but it actually causes other problems. Stress-based motivation causes you to seek relief, sometimes that relief comes from tackling a problem head-on, sometimes that relief comes from avoiding the problem.

Avoiding the problem can lead to more stress (It's a lot more stressful to have a paper that you think you'll do terrible on due tomorrow than it is to have a paper you think you'll do terrible on in a week) but the thing about stress-based motivation is you have less conscious decision about what to do about it. It pushes you, you don't push it. You just help to control the amplitude.

Coffee helps maintain those stress hormones active in your brain, and that stress generally keeps you from sleeping, that's one of it's direct roles, as well as it keeps you worrying which is kind of a positive feedback loop.

First of all, this isn't necessarily a bad thing that needs to change. This is just a thing. But it's good to know how to change it. The first thing you would do is drop the Coffee altogether. Coffee's going to amplify this effect, and it's going to keep you awake at night. Proper sleep will help you relieve stress, and it will help you recover some of the more pleasant feeling interest-based motivation.

The next helpful thing would be to start doing some kind of mindfulness training. I like zazen, particularly just sitting. Essentially sitting in a calm place, and letting thoughts come to your mind, but not acknowledging them, more like watching them come and go. If you find yourself thinking about one of those thoughts, that's OK, start watching THAT thought come and go. The same with sensations or anything else. If you feel tired, you feel tired. If you feel hungry, you feel hungry.

If you do this for 15 minutes, it can feel like a very long time, and you will walk away a bit more objective. I like to conclude with a bit more mindfulness where I sort of take stock of my self. I focus on feeling everything across my body in discrete steps, each finger, my palm, my wrist, my forearm, my elbow, etc. Do I feel pain? Do I feel hungry? Do I feel tired? Then I end this step by thinking about what I might need to do to change these things, if I make myself more comfortable, or eat, or rest, will these things be less distracting?

You might find that you are doing too many things, and that's where this stress is coming from. You can go a for a long while with 10 things to do every day and no means to complete more than 8 of them. This is easy to do if you don't ever count them and get by through telling yourself that you can do all 10 if you just put your mind to it, and get frustrated when you fail.

But in slowing down, you might realize that everyone does this, and that while you can do 8 things better by putting 8 things on your plate rather than do 8 things poorly by putting 10 things on your plate, there's a cultural expectation that you have 10 things on your plate and be exasperated about it, and it's easy to fall into a trap where you're now getting stress from the knowledge that you would really like to have to do 8 things, but you need to do 10, added to the rest of the other stressful feelings you get from having to try to do 10.

Similarly everyone's mind is different, and we all learn to adapt to a different mental landscape. Some people, like people with ADHD, have minds built such that they blow through all of their interest-based focus very quickly. Then their mind wanders easily, and they might turn to stress-based motivation to get through the rest of the day. If you are like this you might be able to avoid the overthinking and the self-medication with coffee, but realize that you need to have a 3 hour work-day in order to not fall into that pattern, which is unreasonable. Or you might be prescribed medication which has it's own sets of upsides and downsides.

My only answer is, you can't really tell your mind to shut up. You're not really the boss of your mind, your conscious thought is just a part of your mind. You can learn about what's going on inside your mind, and you can even put yourself into a situation where you mind can become quiet. But you can't strongarm your whole mind into acting precisely the way your consciousness wants it to act indefinitely. It's much better to just learn how different parts of your mind work, and work to support them. Stress can be great, it's entirely necessary, it's not something you want to cut out of your brain. But it's suited to dealing with crises, and if you can arrange your circumstance so that you aren't using stress to be the motivation through your every day, you might be better off.