[TIMOB-18175] (3_5_X) Check if ViewController dismissal

Cherry Pick PR #6468 into 3_5_X

Fixes [TIMOB-18175](https://jira.appcelerator.org/browse/TIMOB-18175)