No, he did not literally die. Jonah was using poetry to express very deep fears. The earth was closed off to him while he was in the belly of the fish. He was a prisoner behind bars. The use of "forever" in prophesy and metaphor often expresses the emotions of the moment, the sense that he had that he might never see dry land again.
I like Clarke's commentary on these verses:
Verse 5
"The waters compassed me about even to the soul - So as to seem to deprive me of life. I had no hope left.
The weeds were wrapped about my head - This may be understood literally also. He found himself in the fish's stomach, together with sea weeds, and such like marine substances, which the fish had taken for its aliment."
Verse 6
"I went down to the bottoms of the mountains - This also may be literally understood. The fish followed the slanting base of the mountains, till they terminated in a plain at the bottom of the great deep.
The earth with her bars - He represents himself as a prisoner in a dungeon, closed in with bars which he could not remove, and which at first appeared to be for ever, i.e., the place where his life must terminate.
Yet hast thou brought up my life - The substance of this poetic prayer was composed while in the fish's belly; but afterwards the prophet appears to have thrown it into its present poetic form, and to have added some circumstances, such as that before us; for he now speaks of his deliverance from this imminent danger of death. "Thou hast brought up my life from corruption."
Verse 7
"When my soul fainted - When I had given up all hope of life.
My prayer came in unto thee - Here prayer is personified, and is represented as a messenger going from the distressed, and entering into the temple of God, and standing before him. This is a very fine and delicate image. This clause is one of those which I suppose the prophet to have added when he penned this prayer."
Verse 8
"They that observe lying vanities - They that trust in idols, follow vain predictions, permit themselves to be influenced with foolish fears, so as to induce them to leave the path of obvious duty, forsake their own mercy. In leaving that God who is the Fountain of mercy, they abandon that measure of mercy which he had treasured up for them."
Verse 9
"But I will sacrifice unto thee - I will make a sincere vow, which, as soon as my circumstances will permit, I will faithfully execute; and therefore he adds, "I will pay that which I have vowed."
Salvation is of the Lord - All deliverance from danger, preservation of life, recovery from sickness, and redemption of the soul from the power, guilt, and pollution of sin, is from Jehovah. He alone is the Savior, he alone is the Deliverer; for all salvation is from the Lord."
Source: here