Even before putting your investment property on the market, it is a very good idea to speak with your accountant and determine your financial goals. Many sellers go through the hassle and costs of setting up an exchange when their taxable gain is minor or when the timing is such that it might make sense to pay the capital gains tax. A 1031 like-kind exchange can be a great way to defer capital gains on an real estate investment, but often it isn’t necessary.
Can you avoid paying the capital gains tax at all? Yes, there are a few ways, but I can’t recommend dying. In fact I won’t recommend anything other than to say, again, speak with your accountant. However, if you use an investment property as your own personal residence, there may be an opportunity to avoid all tax.