What the error means
You tried to close a token account for a Token-2022 token that charges a transfer fee. The account still holds fees withheld from earlier transfers, so Solana refuses to close it and lose that balance.
Fix
- Run a harvest on the account so its withheld amount moves to the mint. Anyone can do this, and the spl-token CLI has a harvest-withheld-tokens subcommand.
- Close the account again. The rent returns to your wallet.
If it still fails
- Make sure the token balance is zero as well. Only empty accounts can be closed.
- Check that you own the account.
Related: how to collect Token-2022 transfer fees and how to reclaim SOL rent.
