I did other tests here and I understood what happened, I'll try to explain.
In development mode, when uninstalling the add-on, I noticed that the files were not deleted. So I configured it to delete the directories when uninstalling the add-on (in setup.php), and when trying to reinstall it, the files no longer existed. But this procedure doesn't show any error messages, it reinstalls normally without errors, so I didn't understand what was happening and this is why I posted here.
In production mode it showed error messages, the files were deleted, but not the directories (the full path remained), but it was not possible to reinstall or delete, as the files did not exist. It got stuck.
Then I realized that I can't delete these directories via the setup file, right? I removed the file deletion process in setup and it is working now, but in production the add-on directory path still remains, even without the files. Is there another way to erase this path or do I have to keep it?