Very similar situation to you, midlife crisis is a real thing. It's entirely reasonable, it's entirely based on fact and logic.
The only way I can handle it is be keeping a running gratitude list in my head.
At the moment your circle of influence is pretty small, but you're vital. Not everyone is going to rule the world, get a PhD, build a house, or create a successful charity.
It doesn't mean you can't still do lots of things, but this is where you are right now.
With good health you could easily have another 30 years of creating, working, learning, getting/ staying strong, but just start now with hugging your children, and take a deep breath.
Middle of the night panic attack, or feelings of existential dread are realistic because we're aware of our own mortality, but by the same token, that same self-awareness means you can keep deciding to give more head space to the good stuff.