When it comes to minimizing capital gains tax, it all boils down to smart timing and a bit of forethought.