There must be something fascinating about the sound of breaking glass, because broken windows are used as a metaphor often. Imagine a friendly baseball game in which a two-run double becomes a broken living-room window next door. The broken window has two effects: the damage done to the window itself, and the damage done to the relationship between the hitter and the homeowner.
And so it is with sin. When we commit a sin, that sin has a double effect, an "eternal" one and a "temporal" one.
First and foremost, when we sin we wound our relationship with God. He has given us a law to live by in order to draw us to Himself, and to keep us healthy so we might have "life in abundance" (Jn 10:10). Our sin results in hardening our hearts against God, and closing ourselves off to His grace in some measure. A mortal sin completely destroys our communion with God, and with that, destroys our capacity for eternal life (1 Jn 5:16-17). The theological term for this is eternal punishment since we can have no life apart from God. A venial sin is less damaging, diminishing God's life within us without completely removing it. In a way we're "spiritually sick."
The second consequence of sin is our diminished capacity to love and our weakness for further sin. This is the "broken glass" aspect of sin. The Catechism of the Catholic Church speaks of this sin-induced weakness for more sin:
This results in perverse inclinations which cloud conscience and corrupt the concrete judgment of good and evil. Thus sin tends to reproduce itself and reinforce itself, but it cannot destroy the moral sense at its root. (#1865)
In our example, the ballplayer becomes a penitent, sheepishly approaching the homeowner and asking forgiveness for breaking the window. Our homeowner, being a benevolent baseball fan, forgives the ballplayer for his "shattering" play. In the same way, Jesus Christ, through the ministry of the Church, forgives the penitent who approaches Him in the Sacrament of Reconciliation. Through Reconciliation, we open our hearts again to the life of God, and allow sanctifying grace to flood back into us. In the embrace of Christ, we can rejoin the family of God and return as a prodigal to our Father.
But there's still the matter of the broken window…
In our fictional analogy, the ballplayer makes restitution to the homeowner, working odd jobs until he's paid for a new window. The cost of a new window helps the ballplayer understand that playing baseball that close to a plate glass window is a bad idea, and helps him remember to choose a different field next time. He's "learned his lesson" so to speak.
In the spiritual sense, we need a way to "learn our lesson" and detach ourselves from the sin that we have committed. That way is called an indulgence. Through an indulgence, we are able to move from forgiveness in the Sacrament of Reconciliation, to mending the damage, or healing the weakness, brought about by our sin. This is referred to by theologians as the temporal punishment for sin.
To be clear, an indulgence is not "salvation by works" because we are only spiritually able to receive the grace of an indulgence after we've received forgiveness of our sins, as well as received Christ in the Eucharist. The work performed is not unlike the work our ballplayer does around the house where he broke the window, a way of using time-proven spiritual "exercise" to remove our attachment to the world.
The Catechism continues:
While patiently bearing sufferings and trials of all kinds and, when the day comes, serenely facing death, the Christian must strive to accept this temporal punishment of sin as a grace. He should strive by works of mercy and charity, as well as by prayer and the various practices of penance, to put off completely the "old man" and to put on the "new man." (#1473)
To complete our analogy, just as the ballplayer asked and received forgiveness from the homeowner, we can approach Jesus Christ to receive forgiveness for our sins. After we have received forgiveness, we can then tap into the river of grace that flows from Heaven to remove our attachment to sin, just like the ballplayer performed work around the homeowner's house to pay for the broken window. Simple put, if we are busy doing good works, we lack the time to do bad ones. We therefore discipline ourselves (with God's grace) to avoid the next sin, and grow in closeness to God.
And we get a brand new "window" in the bargain.