Twitter/X closed shop because, after stating that they would not comply with these requests, the judge threatened to jail every Twitter/X employee in brazil in retaliation. So to avoid putting these employees/people in danger they chose to immediately close all offices.
Something similar happened in Argentina with twitter as well I believe, and in that case they relocated most of the employees and their families via political asylum in Brazil at the time, if i'm not mistaken.
In Brasil's case he decided to abruptly pull out if the country.
[1] https://arstechnica.com/tech-policy/2023/05/musk-defends-ena...
[2] https://theintercept.com/2023/03/28/twitter-modi-india-punja...
If you want to connect the thread, look into what kind of leaders Bolsonaro, Modi, and Erdogan are.