If you don't want physical delivery, then you have to sell your futures contract before it expires. And what happened on April 20th is that oil prices went negative since there are lots of sellers and very few buyers. Then where were those futures contracts sold to when there is no buyers? was it coming back to the producers who created the contracts? I am new in trading so I am confused a lot. Thank you so much for your help in advance!
Then where were those futures contracts sold to when there is no buyers?
I'm not sure where you got the information that there were no buyers. There were buyers, and the contracts were sold to those buyers.
Every trade is both a purchase and a sale; it's purchased by some buyer and sold by some seller.
If there ever were no buyers, then it would be impossible to sell. There are always buyers, however. On April 20, demand for crude oil was so low that there were fewer buyers at $0 than sellers at $0. But there were equally many buyers at -$37 as sellers at -$37, so that's where the price ended up going.
On a futures exchange, the exchange changes contract open-interest count based on order flow.
Here is a link for open-interest: https://www.cmegroup.com/education/courses/introduction-to-futures/open-interest.html .
Both the example and the CFTC Commitment of Traders indicate that the open buy-contracts and the open sell-contracts don't necessarily balance. So the futures exchange would seem to be the counterparty for the imbalance. But if there is an imbalance at delivery, some contracts will not ultimately require or offer a delivery. Then all the exchange really has to be is an accountant and the stability of the futures market is explained.
There are also market-makers on futures exchanges that buy at the Bid and sell at the Ask. But because the number of contracts can change then the market-makers on a futures exchange don't have very much actual requirement to provide liquidity to the order flow.
Here is a link to a college course: