[TIMOB-17712] (3_4_X) iOS8: Avoid race condition on dismissal of modal window

Cherry Pick PR #6204 into 3_4_X

Test is in [JIRA](https://jira.appcelerator.org/browse/TIMOB-17712)