they were prisoners suffering in chains
11 because they had disobeyed God’s instructions
and rejected the Most High’s plans.
12 So God humbled them with hard work.
They stumbled, and there was no one to help them.
13 So they cried out to the Lord in their distress,
and God saved them from their desperate circumstances.
14 God brought them out from the darkness and deep gloom;
he shattered their chains.
15 Let them thank the Lord for his faithful love
and his wondrous works for all people,
16 because God has shattered bronze doors
and split iron bars in two!
It happens slowly, gradually, step-by-step until suddenly, you realize you have been listening to lies and you are surrounded by darkness. Not that you necessarily "disobeyed God's instructions" or "rejected the Most High's plans" as much as you looked at the dark side of things. You didn't praise God for the beauty, but instead majored on the minor little flaws. And then, suddenly, the whole world seems dark and gloomy.
Then, if you have sense, you cry out to the Lord, and he delivers you. Unfortunately, I don't always have sense, and so I wander around in the gloom for a bit before I realize I'm there, making those around me miserable by my gloom. But, eventually I realize what's happening and then cry out to the Lord, who then brings me out of the darkness and deep gloom, or in the words of another psalm (30:11–12):
11 You changed my mourning into dancing.</idle musing>
You took off my funeral clothes
and dressed me up in joy
12 so that my whole being
might sing praises to you and never stop.
Lord, my God, I will give thanks to you forever.