Rotting usually means there is too much moisture.
To prevent this from happening in the future, make sure the soil around your succulent has excellent drainage. When I have a succulent in a humid or low-airflow location, I usually start with a soil that is intended for succulents (like Miracle Gro or others) and then dilute it 50-50 with pumice or perlite. (Sand is another alternative, but it needs to be special washed sand that is intended for plant use -- random sand from your yard or a playground often contains elements that will hurt your plants.)
If your terrarium is moist all the time, you may even want to consider putting the succulent in 100% pumice or perlite. Succulents can often grow just fine under those conditions. That said, it is also possible that your terrarium is just too moist for a succulent to ever really thrive in there -- though it's difficult to know for sure without knowing more about your setup.
If you want to recover your rotting plant, your best shot is to cut away absolutely all of the rotted parts with a sharp knife, throw out the soil in which it was rotting, and replace it with fresh well-draining soil. If it is adjacent to plants that need soil that retains water, try building up a little hill to elevate the succulent so that it can drain while the others get the wet soil. Alternatively, you could also put your succulent in its own little well-draining container within the terrarium.
It's also worth noting that different succulents have different moisture needs. Generally, succulents with thick leaves need less frequent watering (and rot more easily) than succulents with thin leaves. Consequently, thick-leaved succulents typically need better-draining soil (with more pumice or perlite) than thin-leaved succulents.
Here are some examples of thick-leaved succulents:
And here are some examples of thin-leaved succulents:
Other examples of thin-leaved succulents include most sempervivums and varieties of the Crown of Thorns plant (Euphorbia milii).More questions on Plants: