Based on your excellent but abbreviated (not by your choice) trip report, I presume that this relates to your flight IAH-BGR (sort of)-EWR.
There are no exit formalities from the US. While CBP may choose to inspect departing passengers and sometimes does, there is no standardized process and thus there is no demarcation point such as a passport control station as might occur in other countries.
In your case, you were onboard a US carrier and never left US airspace. Had the flight been cancelled at EWR requiring passengers to deplane, UA & CBP would have dealt with what level of clearance was required. In theory, CBP could have inspected luggage for duty free which ought to have left the US and it might have dealt with visa overstays depending on dates, but it has that information from SecureFlight, so most of that can be handled in the background and if there is an issue, with the very few pax for whom it is a problem.
Ultimately, you are "at or near" the border so subject to inspection. Thus, whether you have "legally" left the US isn't really the issue.