Major losses this year

I sold a lot of loser stocks this year and have over 500K in losses.  414K are short term.  I have long term gains in stocks that I could sell matching those gains with the losses, that way avoiding any tax.  Would that work?