The best way is to have a contract written out, in advance, detailing how the property will be divided if one or both of you decide to sell.

One possible approach if you wish to keep the home is for you to get an appraisal (or for you both to agree to use the lender's appraisal for the refinance) to determine the equity, and pay him half of the equity. Be careful about quit claim deeds in advance of refinancing, as opposed to simultaneously with refinancing, as they may not be permitted under your mortgage contract. You can try to decide between the two of you whether closing costs should be divided equally.