That's the same car I have except I have twice as many miles. My pack was replaced under warranty, but I still live in fear that it could fail any day. After all, the new pack probably has more miles on it than yours does although not as long on the calendar odometer. For the free spinning motor I think what you actually need is a "drive unit" which is the AC induction motor and its inverter. It actually sounds like the motor and inverter are ok (since you can spin it up), but it sounds the gearing or spline has failed. In the modern era of swap-out repair, unfortunately you may have to replace the entire drive unit even though most of it may be ok.
In my opinion, it is unacceptable for a drive unit to fail. There is absolutely no reason they can't be designed and built to outlast the rest of the car. I can point to examples of EVs from the 1990s that are still in daily service running on the original motors (the inverters were upgraded in the 2010s). That being said, the 2013 models are pretty early (for Tesla) and obviously have some design weaknesses. There are some threads in this forum that talk about drive unit problems. You should be able to find them to get a better understanding of the common failure modes.
For the battery, I would ask Tesla for the details on the faults they are observing, report back here, and also consult with the user AustinP recommended. Assuming that they are right and you actually need a replacement pack you are, unfortunately, Exhibit A, as to why these older cars aren't going to stay on the road.
If you just needed a drive unit, and you could actually get one, probably no problem. Sure, it's expensive, but still worth the repair. If you just needed a battery, and they were in stock, that price isn't too crazy and the warranty is decent. The problem is you need both and neither part is likely to be readily available. It's pretty crazy to have to sell a well-cared, low-mileage car at a fire sale price. It's also pretty crazy to spend $18k to keep a 2013 on the road. Maybe, just maybe you would do it if the parts were available and everything else was rock solid. But that's not the case. Long waits for parts. Door handles. Navigation SD cards dying. Death by a thousand cuts. Assuming you can't find a 3rd way, you have only crazy options. Try asking Tesla to split the repairs with you as a gesture of goodwill.
I'm telling you it won't be long before these expensive disposable cars are going to catch the attention of politicians. We desperately need to end the era of sole-sourced traction batteries. If it ever happens, it will be too late for us owners of the early models.