Likely cause
Constant stress from professional or personal life can be the most common reason for the overthinking.
In females it's more than males, because of the hormonal imbalance. Especially during periods or menopausal age. People tend to overthink at night when they have free time and has nothing to do.
What to watch for
If thoughts are contstant and triggering then you definitely should visit doctor and seek professional help. Thoughts of any self-harm or suicidal thoughts are total red flag, you shouldn't avoid this sign and seek help as soon as possible.
What you can do
Try to be around people don't stay alone. Engage your self in conversation or anything which will help you calm down for a while. These are the option to divert or distract your mind from the things bothering you.
When to see a doctor
If thoughts are suicidal or any thought related to self harm, don't stay alone, immediately call your closed one or if you don't have anyone to talk then call the helpline number, they will help you. And when you calm down a bit then visit a therapist take professional help. There is nothing in this world that can't be figure out.
This is general information from a verified doctor and is not a diagnosis or a substitute for an in-person consultation. In an emergency, seek immediate medical care.