Patriots quarterback Tom Brady has agreed to a contract extension that will keep him with the team through the 2017 season, or when he’s 40 years old, according to a report.

Brady’s deal almost assures he’ll retire a Patriot, according to Sports Illustrated’s Peter King, and will save the Patriots more than $27 million over the next two seasons.

The contract, King reports, will pay him less money over time but allows the Patriots greater flexibility.