Imagine a government wants to ban XMR. Is it possible for them to do so?

Yes a government could pass a law banning the use (mining, running a node, participating in a transaction, etc) of Monero.

Even assuming perfect compliance with the law in countries where Monero is banned the blockchain will continue on so long as miners somewhere in the world support it and nodes relay the transactions.

Miners and nodes exist in many different jurisdictions so even a coordinated effort between multiple governments to shut them down would miss many countries. Nodes can be easily set up at remote data centers and efforts such as Kovri will make it much harder to identify the locations of Monero nodes in the future.

Is it possible for an adversary to shut Monero down?

From a practical standpoint, forced shutdown at the direction of a central actor would be almost impossible. Every Monero user has the ability to control their own private keys, mine and run their own node.

Because Monero is used worldwide, in the short term 51% attacks are likely a more legitimate adversarial threat to the Monero blockchain than regulation. The cost of such an attack would be more expensive today than it was two months ago and will vary over time based on the hash rate of the attacker compared to the rest of the network.

Other adversarial threats include the and exploitation (prior to any fix) of flaws in the cryptography or implementation of Monero or in the long run quantum computing. In the case of Monero cryptography and implementation issues the Monero Research Lab and the growing list of Monero contributors continually search for and attempt to solve vulnerabilities. Quantum computing is not a threat in the short term, nor is it unique to Monero. Monero Research Labs plans on spending time identifying and finding solutions to quantum computing problems before they arise.