Hello and thank you for your question.
Consider yourself fortunate that you have a shareholder's basis worksheet.
The capital gains that you recognize increase your basis, as that basis increases and decreases with the income and deductions of the s-corp. If you have a loss coming from the s-corp, it will decrease your basis should you recognize it, noting that if you have no basis, your loss is not deductible.
No, you should not reduce your capital gains by your basis... If you have a capital loss upon wrapping up your s-corp, then you can offset capital gains with that capital loss. Form 1040 Schedule D will be of assistance to you.
Let's review now. You have a basis in your s-corp shares. Initially it was equal to your capital contribution to the s-corp, but then as time went on, your basis rose and fell with the s-corp's earnings and deductions showing on your Schedule K-1's. When you receive a final Schedule K-1, you know that there is no more s-corp activity, so you are ready to look at your final basis at that point. If you have basis left and there is no more money or assets in the corp that can be distributed to you, then you will have a loss. If you receive money or assets from the sale/disposition of your s-corp that exceed your basis, then you will have a gain.
IRC 1244 can apply to s-corps, meaning you may have an ordinary loss on your disposition as opposed to a capital loss. IRC 1244 is here:
With an s-corp you need very good documentation from day 1 if you are going to be able to substantiate your 1244 loss. From the above section, "In the case of an individual, a loss on section 1244 stock issued to such individual or to a partnership which would (but for this section) be treated as a loss from the sale or exchange of a capital asset shall, to the extent provided in this section, be treated as an ordinary loss."
If you are not readily familiar with the concept of shareholder basis and your final computations, then I do strongly suggest you see a local tax professional. Hopefully IRC 1244 can apply. Without knowing any better, you could inadvertently cost yourself some money depending on the size of your s-corp and what is at stake. If we are talking $200 or something as opposed to $20,000 or $2,000,000, that of course makes a difference too.
Thank you again for your question!