The Treaty of Tripoli signed in 1796 by President John Adams:
Art. 11. As the Government of the United States of America is not, in any sense, founded on the Christian religion; as it has in itself no character of enmity against the laws, religion, or tranquility, of Mussulmen (Muslims); and as the said States never entered into any war or act of hostility against any Mahometan (Mohammedan) nation, it is declared by the parties that no pretext arising from religious opinions shall ever produce an interruption of the harmony existing between the two countries.
He's a Major with 13 years of service so he has already completed his obligated term of service long ago. Unlike enlisted personnel officers are not on a strict contract and can request to resign their commission at any time after their initial obligation. He requested to resign his commission late last year and the Army accepted his resignation in January so he will be honorably discharged in June. He will miss out on the pension that kicks in after 20 years of service however.