Depends.
Some are broken down for parts. Some get broken down and recycled. Some get used as a display piece and end up being inherited.
But, yeah, you can just chuck them in the trash. You aren't supposed to, but it isn't like an unloaded and busted up gun is dangerous. If you dump a bunch and the atf gets wind of it, expect some uncomfortable time spent explaining yourself. But a single gun? Nobody will even know unless they go looking through trash. But the atf does have guidelines for destroying firearms, and you can always turn them in to police or the atf and they'll get the job done.
Right now, I have a shotgun that hasn't worked in maybe sixty years. No parts available because it's just that old and nobody makes them. I'd have to have someone make the parts it needs. But, it was my great, great grandfather's, so I just keep it clean and protected.
But, I picked up some firearms a few years back from a lady that wanted to get rid of her deceased husband's collection fast and for cash. One of them was not only in horrible shape, unsafe to fire, but it was illegal. Broke it down, recycled what could be, sold the few parts that were usable, then trashed the rest.
Truth is, most guns are going to last a couple of generations since the moving parts can be replaced for anything that's popular enough. Like the 1911, as a perfect example. Some of the originals are out there, still in shape and safe to use because you only need some of the parts replaced as they wear out; the main body of the gun isn't going to just fail in normal usage. Tens of thousands of rounds through some of them.
So the only time a gun wears out is when you can't replace what breaks, or what breaks is the parts that would essentially mean you're buying a new gun rather than repairing an old one.
There's guns from the 1800s still being used out there. Not as many as there used to be because they're fairly valuable, but still. Same with stuff even older, though the older they are the less likely they are to every be fired again, no matter what condition they're in.
My cousin has an old garand my grandfather gave him that he still shoots weekly, and it was carried in action. That thing is damn near a century old, and has been all over the world. I've got an old mauser rifle from the same era that's in great shape, if not exactly ideal since it was sporterized.
If you were asking because you needed to dispose of a damaged firearm, I'd say you should check your local laws first, and then hand them over to whatever state, province, or equivalent for your country's law enforcement is. Mainly to cover your ass. But in the normal course of things, if you render it unrepairable, nobody is going to care what you do with what's left