Sold schedule c rental home

We bought a second home in 2005 to flip but ended up renting it since then. We reported rental income and expenses including depreciation on Schedule C, netting out to a small loss on paper (less than $10k each year) using Turbo Tax Premier.  We sold the house in 2021 for $348k (sale price less realtor and other fees) and our purchase price was $381k (price plus closing costs and related expenses). Total depreciation taken thru 2020 (per TT) is $173k. Do we use Form 4797 to report this sale? How much is Schedule C depreciation in 2021 since we didn't own the house all year? And there's a net loss based on the sale and purch prices, but with depreciation TT is calculating a gain of $140k - do we owe capital gains tax on this amount?! Thank you.