UIViewController *mainViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
    if([mainViewController isKindOfClass:[UITabBarController class]]){
        UIViewController *modalViewController = [mainViewController modalViewController];
        if(modalViewController && (id)modalViewController != [NSNull null])
            [mainViewController dismissModalViewControllerAnimated:NO];
    }
Bam.