@Jordi *******
if you haven't bought a re-entry permit yet, for this second-year stay permit, you just EXIT Thailand and the stay permit will become invalid. Only at this point the road is open and you will be able to apply for a new visa or be able to re-enter Thailand on another reason. Then you either re-enter visa exempt, or with a Tourist Visa and apply on Immigration for the "change of visa type" from a tourist visa or visa exempt entry, to a 90 days Non-immO married visa. Or get a 90 days Non-Imm-O married visa on a Thai consulate in a neighbouring country, which requires you take your wife with you and all the proofs for your marriage and a financial proof (400,000 THB in a bank account in yxour sole name or 12-months transfers of 40,000 THB or income affidavit if applicable)