After upgrade to 8.1.39, an App I didn't wrotten but I maintain has a strange behavior :
On only one view, system.nav.swapWindow(xxx) displays the good view but the script on the from view is still executed.
The script is linked to a button (actionPerformed)
if blabla :
[...]
system.nav.swapWindow(xxx)
print "why this line is printed ?"
In this example, the line print is executed (and the end of the script too that is finally crashing).
Why would you expect the script to terminate after calling a system function?
If it's necessary to terminate a script at a given point, put it in a library script or custom method. Then, return can be used to stop the code at any point.
What is the script from the line that is "crashing".
The solution is, that you should not execute any script following navigation away from a window that expects components on the window you are moving away from to still exist. The original author of the script set you up for failure there. If that part of the script needs to execute, then move it prior to the navigation.