August/September/October 2018 is going to be a real interesting month for CPO sales for P90D and P90DL cars. A lot of these cars were leased and a lot of owners will turn them in. It will take Tesla 2 weeks to add them to CPO after you turn them in. And there will no doubt be a P90DL that pops up every now and then before August. Hopefully that will give you a little time to gauge the market.
If you opt to not keep the car Tesla will have to sell it at the going rate. Residual value won't matter. The market price should be fairly well established. If the $7500 new car credit is gone that will tend to increase the CPO car values. Who knows how AP2.0 will affect anything or whatever else Tesla introduces in the next 2 years.
I don't know how your lease works but I would prefer to get a 4 year warranty on a 2 year old high performance car if I bought it outright. Are there any terms for extending the lease? Depending on the CPO market for P90DLs maybe you can negotiate a price other than the residual value. Maybe you can negotiate a warranty extension. Either way you have to come up with beaucoup cash.
My guess is the market will bear a P90DL with 40,000 miles in the $90-95,000 range.