Bug fix for when returning to the calling site outside of the popup window

The previous code assumed that if you used the popup window option, then control would return to the calling site via the popup window. In our case, if the user creates a new account, they return via a link in an email that does not open in the popup, causing the calling site to crash when a return is attempted.
The fix checks for window.opener being present before deciding what to do with the return of control.