Does training up a child always work out in the end?
My answer: No, not always.
While your question contains many concepts I can agree with, an important concept that is missing in your answer is the concept of the sovereignty of God, on the one hand, and the free will of His image bearers, on the other hand.
The book "The Sovereignty of God and the Free Will of Man", written by A. W. Pink, the late theologian, Bible teacher, pastor, and writer suggests that God's sovereignty and human free will constitute an antinomy. In other words, they present us with a paradox.
On the one hand, God is sovereign. In spite of the sins and machinations of fallen humanity, God's overall plan for the ages will come to pass. There will come a time when, as the seventh angel in Revelation 11:15 says, "The kingdom of this world has become the kingdom of our Lord, and of his Christ; and he shall reign for ever and ever."
Yes, God will one day triumph over evil and will usher in His kingdom in which "righteousness will cover the earth as the waters cover the sea" (Isaiah 11:9 and Habakkuk 2:14). One day there will be a great and unbridgeable chasm between hell and the new heavens and the new earth. God's will WILL always be done "on earth as it is in heaven."
On the other hand, there is the freedom of God's image bearers. Exactly how and to what extent God's sovereignty and our free will coexist has been debated for millennia by greater thinkers than I. Where God's sovereignty "makes room" for the free will of His creatures, and where our free will ends and God's sovereignty trumps our free will presents us with a paradox.
Let's apply my thoughts above to the question at hand. You quoted Proverbs 22:6: "Train up a child in the way he should go; even when he is old he will not depart from it." You then asked "Does training up a child [in the way he should go] always work out in the end?" I say no. Why? Because there are simply too many exceptions to the rule, and the book of Proverbs, by its very nature, allows for exceptions to the rule.
Is gray (or white) hair always "a crown of splendor . . . attained in the way of righteousness"? (See Proverbs 16:31.) No, there are many men and women whose gray or white hair is NOT a crown of splendor, nor is it attained by living a righteous life.
Similarly, not every child who is trained up in the way s/he should go will end up living that way when their parents die. The fault for this sad outcome of a life is shared by parents and children alike.
To train up a child in the way he should go means, in part, that since each child is unique and has a certain "bent" in their approach to life, parents can fail their children when they neither recognize that bent nor do they parent their children according to that bent. By the same token, there are parents who do an excellent job in rearing their children by allowing them to express their individuality, their temperaments, and their choices in God-honoring ways.
There are, however, parents who live their lives through their children. Take the father who is a doctor, lawyer, laborer, or engineer, or the mother who is a nurse, a professor, a homemaker, or a statistician. Ignoring their child's bent, they might exert undue pressure on the child by insisting s/he become a doctor when the child's heart is simply not in it.
Children, too, bear responsibility for how they turn out spiritually later in life. Their parents may have done a good job in rearing them according to their children's bent. The parents prayed with their children, took them to church and Sunday school regularly, and spoke freely to their children about biblical values and how to apply those values to lives that are pleasing to the Lord.
By the same token, however, the children sometimes rebel against those biblical values, sometimes for a brief time, and sometimes for many years. While their parents may not have done a perfect job in bringing their children up, are the parents solely to blame for children who make shipwreck of their lives? No.
Here is where God's sovereignty and human responsibility are especially relevant. You've heard the expression, I'm sure, that "It's not a matter of either/or, but of both/and." So it is with God's sovereignty and human responsibility. Both exist in equipoise, but how exactly that equilibrium is achieved is difficult to say. I suggest that God's sovereignty and human freedom will, until the end of history as we know it, exist in tension.
To insist that a verse such as Proverbs is an inexorable rule to which their are no exceptions is a mistake, in my opinion. Furthermore, to insist that our heavenly Father has somehow failed in His child-rearing because some of His children do not finish their course well is a mistake. They, unlike the apostle Paul, will simply not have a crown of righteousness awaiting them (2 Timothy 4:8) and will experience a loss of reward.
In conclusion, all believers will one day be judged by God at the Judgment Seat of Christ (2 Corinthians 5:10; compare 1 Corinthians 3:10-15). Believers will lose rewards when their ostensible good deeds are judged by God to have been motivated by impure motives. Those motives are the wood, hay, or straw mentioned in 1 Corinthians 3:12. Believers will gain rewards, however, when their motives are judged to have been pure, and when their works live on ("echo in eternity"). Those are the gold, silver, and precious stones the fire of God's judgment will not consume.
As for unbelievers--because even children brought up in the way they should go will not inherit eternal life, ultimately their final destination is determined by their names not being written in the Lamb's book of life. Their punishments, however, will be commensurable with the severity and extent of their sins (Revelation 13:8 and 21:27).