Let's take a look at the overal context in which this particular parable is related or taught.
For this, we'll simply take the whole chapter, because I believe it's pertinent to understanding the teaching of the parable.
Matthew 18
At that hour the disciples came to Jesus, saying: Who thinkest thou is the greater in the kingdom of heaven? And Jesus calling unto him a little child, set him in the midst of them, And said: Amen I say to you, unless you be converted, and become as little children, you shall not enter into the kingdom of heaven. Whosoever therefore shall humble himself as this little child, he is the greater in the kingdom of heaven. And he that shall receive one such little child in my name, receiveth me. But he that shall scandalize one of these little ones that believe in me, it were better for him that a millstone should be hanged about his neck, and that he should be drowned in the depth of the sea. Woe to the world because of scandals. For it must needs be that scandals come: but nevertheless woe to that man by whom the scandal cometh. And if thy hand, or thy foot scandalize thee, cut it off, and cast it from thee. It is better for thee to go into life maimed or lame, than having two hands or two feet, to be cast into everlasting fire. And if thy eye scandalize thee, pluck it out, and cast it from thee. It is better for thee having one eye to enter into life, than having two eyes to be cast into hell fire. See that you despise not one of these little ones: for I say to you, that their angels in heaven always see the face of my Father who is in heaven. For the Son of man is come to save that which was lost. What think you? If a man have an hundred sheep, and one of them should go astray: doth he not leave the ninety-nine in the mountains, and go to seek that which is gone astray? And if it so be that he find it: Amen I say to you, he rejoiceth more for that, than for the ninety-nine that went not astray. Even so it is not the will of your Father, who is in heaven, that one of these little ones should perish.
15 But if thy brother shall offend against thee, go, and rebuke him between thee and him alone. If he shall hear thee, thou shalt gain thy brother. And if he will not hear thee, take with thee one or two more: that in the mouth of two or three witnesses every word may stand. And if he will not hear them: tell the church. And if he will not hear the church, let him be to thee as the heathen and publican. Amen I say to you, whatsoever you shall bind upon earth, shall be bound also in heaven; and whatsoever you shall loose upon earth, shall be loosed also in heaven. Again I say to you, that if two of you shall consent upon earth, concerning any thing whatsoever they shall ask, it shall be done to them by my Father who is in heaven. For where there are two or three gathered together in my name, there am I in the midst of them.
Then came Peter unto him and said: Lord, how often shall my brother offend against me, and I forgive him? till seven times? Jesus saith to him: I say not to thee, till seven times; but till seventy times seven times. Therefore is the kingdom of heaven likened to a king, who would take an account of his servants. And when he had begun to take the account, one was brought to him, that owed him ten thousand talents. And as he had not wherewith to pay it, his lord commanded that he should be sold, and his wife and children and all that he had, and payment to be made. But that servant falling down, besought him, saying: Have patience with me, and I will pay thee all. And the lord of that servant being moved with pity, let him go and forgave him the debt. But when that servant was gone out, he found one of his fellow servants that owed him an hundred pence: and laying hold of him, throttled him, saying: Pay what thou owest. And his fellow servant falling down, besought him, saying: Have patience with me, and I will pay thee all. And he would not: but went and cast him into prison, till he paid the debt. Now his fellow servants seeing what was done, were very much grieved, and they came and told their lord all that was done. Then his lord called him; and said to him: Thou wicked servant, I forgave thee all the debt, because thou besoughtest me: Shouldst not thou then have had compassion also on thy fellow servant, even as I had compassion on thee? And his lord being angry, delivered him to the torturers until he paid all the debt.
Now what does Jesus say next?
So also shall my heavenly Father do to you, if you forgive not every one his brother from your hearts.
Explicitly, believers of Jesus, even while they had their debt of sin forgiven, will be "delivered..to the torturers until" they 'pay' a debt if they imperfectly forgive (used as just an example).
This is also, in the same context about not forgiving as we have been forgiven, what Jesus teaches in Matthew 5. Again, the wider context is overwhelmingly to do with rewards and punishments in the afterlife, in terms of the general title for the goings on within the spiritual kingdom of Christians.
Matthew 5:21:26
You have heard that it was said to them of old: Thou shalt not kill. And whosoever shall kill shall be in danger of the judgment. But I say to you, that whosoever is angry with his brother, shall be in danger of the judgment. And whosoever shall say to his brother, Raca, shall be in danger of the council. And whosoever shall say, Thou Fool, shall be in danger of hell fire. If therefore thou offer thy gift at the altar, and there thou remember that thy brother hath any thing against thee; Leave there thy offering before the altar, and go first to be reconciled to thy brother: and then coming thou shalt offer thy gift. Be at agreement with thy adversary betimes, whilst thou art in the way with him: lest perhaps the adversary deliver thee to the judge, and the judge deliver thee to the officer, and thou be cast into prison. Amen I say to thee, thou shalt not go out from thence till thou repay the last farthing.
Clearly, Jesus isn't giving tips on how to avoid literal prison. Not being moral and forgiving your brother doesn't lead to literal prison. And the last part is not Jesus joking or jumping into parable all of a sudden.
"Prison" seems to have been a name for the 'cleansing' or 'purgatory' or 'world to come' (Matthew 12:32; especially in light of the usage of the word "prison" to mean underworld/afterlife in 1 Peter 3:19) that comes before entering heaven for imperfections to be 'cleansed,' i.e. "forgiven" (ibid.) For example, in the Didache (a proto-catechism/teaching document from around A.D. 70, roughly contemporaneous with the Gospels) we read this applied again to spiritual judgement (cap. I, 5):
- Give to everyone that asks thee, and do not refuse, for the Father's will is that we give to all from the gifts we have received.
Blessed is he that gives according to the mandate; for he is innocent;
but he who receives it without need shall be tried as to why he took
and for what, and being in prison he shall be examined as to his
deeds, and "he shall not come out thence until he pay the last
farthing."
The punishment is not indefinite in either case. Since in both we find a qualifier: "till thou repay;" "until he paid." Which in both cases presupposes the ability to repay. Otherwise He would have said "You shall not go out from hence"..period. Or ever.
Hence, you're conclusions are correct:
That he would be able to pay back what was owed and
That he would somehow be able to do that while in jail and being tortured.
And is actually further reason to understand that this is a teaching on the afterlife: the payment is the punishment. The payment is the perfect upholding of justice for each imperfect deed. (2 Corinthians 5:10). This is distinguised from the eternal punishment which in the former passage, the parable, is the eternal punishment all were saved from by Christ; the minor, temporal punishments for imperfections or lesser misdeeds are 'payed for' in this "age to come." (Matthew 12:32) Called "prison" because it keeps the person from their ultimate goal, heaven "till thou repay the last farthing." Just as Abraham's Bosom, also what would fall under a kind of 'prison' in the afterlife is called "prison". (1 Peter 3:19; cf. Ephesians 4:9).