What concerns me most is the attitude in the statement "he's put too much work into the company to just get fired just because I'm the boss.". This is a person who has access to all the source code for your systems and as a team lead is likely to have production server access. This is a very dangerous person. With this attitude, he may very well be using the code to steal from you or have set up a a backdoor to get in from outside or have set up something in the code to blow up your systems if he is fired. This is not the normal attitude of a person who has been caught in an affair. Since he knew he was having an affair and that it was likely he could be fired if found out, I would be very wary of this person.  He also could be providing your wife with information that will let her take more of your assets. 

The first thing I would do is make sure you have up-to-date backups of everything! And then I would make sure that they were off-site. This type of person is the kind who is likely to have put something into the code to blow it up if he is fired. You need to protect your data and your applications. 

Next, I would hire someone to take his place. I might even, depending on how insecure I felt the data and aplication was, hire this person and have him work at first with a copy of the application and data somewhere outside the office. Then have his first task be to assess if there is a danger to the code from something this other person put in.  I might even look for and hire a security expert as a consultant to do this. 

Now once I have protected my data I would take one of two actions. If you are in the US and work in an "At will" state, I would fire him. Then immediately change all passwords to all servers and databases. 

If you are elsewhere or don't know for sure that you are in a state where you can fire without cause, I would immediately consult a labor lawyer to find out what actions you can take to protect your company. If it is not legally possible to fire him, you might be able to reassign him to a newly created position that has no duties and remove his access to code, databases and servers. (Change all passwords if you do.)

Change all server, database and application passwords.