the thing is, people *are* still buying physical CDs, just way fewer of them. it's not like they vanished overnight. but yeah, the real collapse happened between like 2008-2012 or so. streaming services existed before spotify blew up, but spotify launching in the us around 2011 basically showed people "hey you can have basically unlimited music for $10 a month" and that changed everything. before that, even with services like pandora, cd sales were already dropping because of itunes and people just ripping their own stuff to ipods. so spotify didn't create the decline - it accelerated it massively.
what most people don't realize is that cd sales didn't tank to *zero* though. they bottomed out and now they're actually kind of stabilizing in a weird way. vinyl came back as a collector thing, and cds found this niche market of people who wanted something tangible, or audiophiles who swore the quality was better, or just folks who didn't trust their internet connection. your parents' collection is actually more valuable now as a curiosity than it would've been in 2015 when everyone thought cds were completely dead.
if you're still sitting on those stacks, here's a practical thing nobody mentions: before you toss them, check if any are rare pressings or first editions of albums that became cult classics. some 90s indie releases that seemed worthless at the time sell decent money now to collectors. you can literally photograph the spine and search it online in like five minutes. otherwise, local libraries often take donations, or music shops will sometimes buy bulk collections even if most of it's common stuff.