Fix issue with native controls on iOS 7
Change order of exit functions to fix Safari 5.1