dismiss view if dismiss is called before the view is visible