They can stop them because player transfers don't just spontaneously happen when clubs say that they've come to an agreement. The national FA has to agree to it, and if the two clubs are from different countries, UEFA/FIFA has to approve it too. If Barca genuinely are/were banned from selling players, and they agreed a fee for, say, Xavi, with a foreign club, then the Spanish FA and FIFA would just refuse to ratify the transfer. That would mean that the team he transferred to would not be allowed to register him as a player, and would be penalised cripplingly for playing him in games. Referees would probably simply refuse to start matches where he was playing for his new team.
Think about it. Your question is really no different from asking "how can they enforce a rule saying that you can't sell players outside of the transfer window", and yet I don't remember any club ever trying to get away with blatantly transferring players in the middle of March. The exact same systems which are in place to stop this outside of transfer windows would be used to block Barca from selling anyone full stop. In fact, they're the exact same systems which will prevent them from signing anyone too, and yet no-one is questioning whether FIFA has the ability to stop them buying players.