In countries with an outbound border control you leave the country according to Visa regulations when you walk through the border control and into the transit zone. The transit zone is special secured area which you only can enter and exit through the border control station. Physically you are still in the country and are bound to the rules and laws to this country. This continues until the plane leaves the countries airspace. So if you commit a murder on an US plane in German airspace you will be prosecuted by German authorities under German law. In addition it is possible that another trial can be done in the US because of the fact it happened on board an US plane. I think the US introduced a law that says that a US plane is de facto US soil so they can charge hijackers and terrorists which hijacked US planes outside the US.
In a country without an outbound border control like the USA for example you exited the country according to visa regulations when you return your I-94. It shouldn't be possible to return into the United States without going again through immigration.