This makes me wonder how starships are scrapped in Trek. We know that this is probably done, given possible-future Admiral Riker's remarks that Starfleet wanted to scrap the Enterprise-D before he got them to assign her as his personal flagship (after only 33 years? - but that's a whole other thread). Following today's parallels, a ship would first be stripped of all components that can be re-used in other starships (typically those of her class still functioning, but then also any ship that can use those components), weapons systems, computers, engines, and anything classified. Then the ship would be scrapped and recycled into raw materials for new ships, assuming no one wanted the hull as a museum or to be used as target practice, etc.

Obviously there is a practical limit to this though, and there may be a skeleton of a starship left over, stripped to the point where it's simply easier to create new components than to take the hull apart and forge new alloys from them (this is assuming they aren't using replicators or matter converters, which is a safe bet for the most part). So what happens then? Do we simply send the rest into the local sun?