It’s not at all unusual for lonely children, especially smart and creative lonely children, to create imaginary friends and to develop intense relationships with them. These “friends” tend to disappear when a child goes to school and starts to socialize regularly with other children. The exceptions are kids who are very shy or who are bullied. The shy, the bullied, and the outsiders often continue to keep some or all of their imaginary world alive for a time.
You didn’t share enough of your history for me to make more guesses than that. But what is important is that this habit is now getting in the way of your life and may be even getting in the way of your relationships with your own children.
You are probably going to need some help with this. If you could successfully shelve the imaginary gang, you would have done it already. It would probably be helpful for you to talk to a therapist to gain more insight into the source of the problem and to strategize ways to be more “present” in the present. With understanding and support, you are likely to reach your goal.
I wish you well.