code can cause the brain to freeze, generally that would not be the case with blocks code, more likely with C++ when a program overwrites system memory for some reason.
This could be the cause if it also happens when user programs are not running, usually hardware failure involving flash memory.
If the X button is not responding it’s likely other features will stop working as well, perhaps the program run time display or radio scan indicator.
We have had this happen a few times recently on a gen 1 brain, the only solution is to pop the battery out. This is an ES team using blocks only. I don’t recall if the brain this was happening on was on 2.2.0 or 2.2.1