avoid crash in case of no 'window' property in app delegate

this change was dropped at commit 9967d35635e60e256faf3aa6e78a2ef826d8ad89