Trump knew that he might not get the support of even his inner circle to keep fighting because it was against his campaign promises. I also agree that the economic consequences is another genuine reason why he withdrew from the war. The US is just recovering from a tarrif war, a military war would affect the economy adversely.
The only possibility of fighting Iran is through Israel, and that has already happened. However, it is clear that the Iranian response was unexpected, although it was nowhere near comparable to the Israeli strikes on Iran. However, it became clear to Israel and the United States that Iran is capable of targeting Israeli territory, including major cities such as Tel Aviv and Haifa. Had Iran not responded, the war would have lasted more than 12 days, and Israel would not have needed American military assistance.
Referring to the economic implications, the United States cannot afford the costs of a war against a superpower like Iran, supported by its allies Pakistan, China, and maybe Russia as well. The Trump administration, which promises to reduce government spending, lower taxes, and raise tariffs to boost the national economy, is unable to convince the Americans to enter this war, especially since there is no immediate direct threat and Iran is cooperating to resolve the nuclear issue through peaceful diplomacy.