Bitcoin is a digital currency that circulates freely, without any control or supervision from banks, governments, or anyone else. In contrast, bitcoin relies solely on cryptography and software between computers.
what if the government closes or does not allow the exchange of Bitcoin or cryptocurrencies with the official currency in each country?

Bitcoin was developed and designed to bring about easy peer-to-peer (P2P) transactions, and I think many countries have tried in the past to stop Bitcoin growth in their country, with some saying it is banned and so on. But however, countries can say that or put in measures to stop it, but it is quite proven that you can't stop a growing technology and since Bitcoin has been growing for years till now, even with measures to stop its transactions in a country, people will find their ways around it, peer-to-peer platforms are there and so on. In fact many countries have been doing peer-to-peer transactions for years before it now gets better with exchanges like Binance having their own peer-to-peer features.
Therefore in essence, Bitcoin can't be crashed or stopped totally by the government, there will always be ways around it.