title: NSOpenPanel doesn't close automatically
body: <p>I don't understand why the panel won't close immediately when i click OK button.
  <br></p>
  
  <pre><code>if (NSOKButton == [uploadPanel runModal]) {
      for (int i = 0; i &lt; 10000; i++) {
          NSLog(@"%d",i);
      }
  }
  </code></pre>
  
  <p>Instead, it closes only until all statements in the scope are exacuted.</p>
  
  <p>It is weird that the result turn out the SAME when I change the code into something like this:</p>
  
  <pre><code>if (NSOKButton == [uploadPanel runModal]) {
      NSLog(@"ok");
  }
  
  for (int i = 0; i &lt; 10000; i++) {
      NSLog(@"%d",i);
  }
  </code></pre>
  
  <p>By the way, there is NO such problem with NSSavePanel.</p>
  
  <p>Is there any way to solve the problem?</p>
  
  <p>UPDATE1:
  I have tried the method provided by Abhi Beckert, but still doesn't work :(</p>
  
  <pre><code>if (NSOKButton == [uploadPanel runModal]) {
      NSLog(@"ok");
      [uploadPanel close];
  }
  
  for (int i = 0; i &lt; 10000; i++) {
      NSLog(@"%d",i);
  }
  </code></pre>