If you sign a player to a six year contract and he retires after year 2. All of his bonus money for years 3-6 will count against the first year of his retirement. Example below:
2020 - Salary $4,000,000 Bonus $2,000,000
2021 - Salary $4,200,000 Bonus $2,000,000
2022 - Salary $4,410,000 Bonus $2,000,000
2023 - Salary $4,630,500 Bonus $2,000,000
2024 - Salary $4,862,025 Bonus $2,000,000
2025 - Salary $5,105,127 Bonus $2,000,000
If he retires after the 2021 season. 8,000,000 will count against your cap in 2022.