Added check before dismissing

Otherwise the VC may dismiss itself.
Merge pull request #9 from nheagy/master

Added check before dismissing