Investors & landlords

Yes, you could do a 1031 exchange if you are buying another rental property.  However, I suspect the exchange costs would be MORE than the amount of tax you save, so that probably isn't a good idea.

No, rental time AFTER the last time you lived there is NOT "Nonqualifying Use".  As Critter said, you will only pay tax on the depreciation.