We call it WDU, Withdrawn From Use, when an aircraft is "retired". There are several reasons for retiring an aircraft; Fleet Downsizing, Airframe Time-out, or being replaced by new, more efficient aircraft. When an aircraft is WDU, it goes to a place like Victorville, CA (KVCV), where several things happen.
Sometimes, airlines will place aircraft in storage due to demand being down, and say a route that was operated by a 747-400 can be better, more efficiently, served by a 767-300. They will "mothball" the airplane until they decide to place it back in service.
If the airframe has time left on it, and it's operator has no need for the aircraft anymore, then the aircraft is stored until a new buyer comes along. Take Deltas' L-1011 fleet for example, many of witch had lots of time left on the airframe, some have gone on to serve airlines in the Middle East and Africa, and others have been converted into freighters. Sometimes, that new owner is the airplanes ticket to Hollywood! Movie and TV studios commonly use aircraft for props and sets before they are scrapped.
If the aircraft is timed out, then it will be parted out, and cut up for scrap.
Below are some pics from KVCV:
#1 is a B737-200 of Aloha being parted out.
#2 is the storage yard of air worthy, mothballed aircraft.
#3 is a wider shot of the storage yard.
#4 is all that remains of a Tower Air B747-200 being cut up for scrap.