I think Perez brought a good bit of sponsorship money to the team. That's another reason Haas is looking at him (No matter what Steiner says). If so, the cost of the change is even more than the $40m.
The article estimates the $40 million includes Seb's salary, Perez's payout and the loss of sponsorship.
I assume bringing Seb on board brings sponsorship, just as Alonso brought Santander to Ferrari, and a barrel of cash big enough to pay Kimi not to race. Seb is the only driver representing the wealthiest nation in the EU.
Personally, I'd have kept Perez. Whether or not Seb is better, he's not better enough to win where Perez couldn't. But I don't know what's going on behind the scenes. Perez's sponsors might have expectations that Aston Martin isn't prepared to meet... or vice versa. Perez and Lance might not get along.
Or maybe Aston Martin just needs to clear out the Force India 'culture', which Perez would be a key part of. Seb has been part of two of the strongest F1 programmes, one very successful, and one that struggled. He brings two very important perspectives that Perez does not have. We've also seen that technical personnel are sometimes attached to drivers. There might be some background hiring/firing associated directly with Perez vs Vettel.