As far as I understand, perpetual contracts are like regular futures except they can be held open indefinitely. However, I don't know about any other brokers out there, but in Binance, when you open a perpetual contract, you do so by interacting with an order book, meaning, for every position you open there is an opposite position held by another person (your counterpart). Now this is when my understanding gets a bit fuzzy. Correct me if I'm wrong, but I believe the contract is an agreement to perform a transaction at a pre-defined price, somewhere in the future. So... what happens to my counterpart if I close my position, or get liquidated? I mean, if my position, (let's say, a long), gets closed, then who is going to be there to fulfill my counterparts' short position when he closes his? Does this issue happen with regular futures as well?
Yes, it also work like this for regular futures contracts.
Say you've an open long position in that contract. In order to close it (open a short position so as to get net zero exposure), you'll need someone to go long that same contract. Since the counterparty for all trades is the exchange (Central Counterparty or CCP), the final exposure for each party would be:
You: net zero (long position + short position)
Your first ctpy: one short position
Your second ctpy: one long position
CCP: net zero (two long positions + two short positions)
So your original long position doesn't disappear when you close it.