Zen buddhist philosophy preaches we should always stay in the present moment. The mind wants to wander on about way too many thoughts, and it’s imperative for you to recognize it and then detach yourself from the constantly thinking mind. Take a deep breath and feel the presence in the now. Focus the sensation onto the extremities of the body: the fingers typing on a laptop, your feet touching the cold embrace of the floor. The mind will want to fight you on this, but anytime you see it go off once again onto yet another thought string, let it go and return focus to your breathing.
This practice is particularly useful during stressful situations, or when things aren’t especially going your way. Negative thoughts of fear, anxiety, or sadness will flood the brain channels during these times, and it can be quite overwhelming if you are unable to keep attention to the present moment. The mind will draw from your pass memories, or create future scenarios in order to torture you; I think we can all attest the mind is very good at doing both when we most need it to be calm.
Being in the present is also surprisingly useful when things are going well. Surely you’ve experienced this: the night before a huge trip or big life event, it’s rather difficult to get a good night’s sleep. The mind is preoccupied with great anticipation for the positive things that’s about to happen, and it cannot wait for you to get this proper sleep first - it wants to time travel. So there you are, lying in bed wide awake, the mind full of sweet scenarios of what’s to come. Or perhaps you’re like me: anxious about those future event turning out badly.
Sometimes the mind wanderings are so strong that you just have to let it be. Resign to that fact it’s going to be active for awhile, and simply observe the thoughts as they come and go. It’s useless to waste additional energy to fight it - just observe. The mind will quiet down eventually, and you can then go to sleep.