Get your taxes done using TurboTax

You only have to pay the taxes owed on the withdrawal of the funds from the retirement account.  Any sales of stocks within the retirement fund are not subject to capital gains.