There’s a theological answer that has to do with prayer, the ministry of others in my life, and the unconditional love of God. However, there’s also a sociological answer. It’s not separate from the work of God but rather an understanding of how the creator made us.
Social scientist call it resilience. It’s the mental, emotional, and psychological ability to weather life's storms without long term consequences. There’s a great deal out there on the subject. Some of its too scientific, and some too antidotal. I recommend Dr. Kenneth Ginsburg’s book, A Parent’s Guide to Building Resilience in Children and Teens: Giving Your Child Roots and Wing. It’s a great place to start.
Take Away: Children need both roots and wings.