save the app's window handle internally for reference. it is more realiable than trying to query keyWindow or mainWindow.