When closing a page, the browser history is used to navigate to the previous page. However, navigating to a page in an iframe also adds a history item to the browser history. This means that when closing the page, or pressing the back button, the browser will first start to navigate through the pages visited in the iframe. Only after reaching the starting point of the iframe the browser will start to navigate outside the iframe. When long clicking the back button of the browser it will show you the navigation history, including the navigation history of the iframe.
As far as I know there is no way to prevent the iframe from adding history items to the browser history. Unless you control the page inside the iframe and replace the current history item upon navigation instead of adding one.
What do you mean with "However when we are trying to close the page that the Iframe is loaded into we are seeing the other pages that have been called from the Iframe still open." ?
Furthermore, you stated that you use a custom iframe widget. It is also possible to use the standard html snippet widget from the app store to load an iframe.
Did you add a unintialize function to remove the iframe after the widget is unitialized by Mendix (which happens if the page it is on is closed properly.
We were able to get this custom iframe widget to work with the external application by using an aspect listener to wait for the page to be loaded. This allowed the widget to only call the source of the iframe once.
This code was added to listen for the page to load.
this._aspectListener = dojoAspect.after(this.mxform, "onNavigation", dojoLang.hitch(this, this._someFunction));
This was neccessary because the source of the Iframe could only be called once. After the first call the transfer would not take place. We found that different browsers handle creating iframes differently.