40K is not too bad, my 2017P100DL cost about 178K out the door and now 3 years later, it is worth about 70k, thats over 100K depreciation in 3 years. If Elon keeps reducing prices, the resale value of the S and X will continue to fall drastically.
Sorry for your loss but hopefully you did...