title: iOS - How to remove all ViewControllers in the applications window hierarchy?
body: <p>My app uses a typical authentication scenario, where the user logs in with his credentials against the server, which is returning an authentication token which is then stored locally on the client (iPhone).</p>
  
  <p>Now it is not likely but possible the stored authentication token gets invalid over time. As every request made with that invalid token would fail, I want to handle that by "logging the user out" of the application when that failure occurs for the first time. Note: that request may be made in a <strong>background thread</strong>, because the app is synchronizing with the server periodically.</p>
  
  <p><strong>Logging out means:</strong> </p>
  
  <ol>
  <li>Deleting the locally stored token</li>
  <li>Deleting all the other content stored by the user (in Sqlite)</li>
  <li>"Redirecting" the user to the login controller</li>
  </ol>
  
  <p>So it is possible the user is viewing some content within the app, while the token gets invalid and the sign out process gets started.</p>
  
  <p>As all content gets deleted (#2) it is not sufficient to present her the login controller, because after logging in and dismissing that controller the previously content isn't really there anymore.</p>
  
  <p>To prevent these kind of side effects I want to completely remove all view controllers in the hierarchy, regardless how deep it is when the logout is triggered.</p>
  
  <p><strong>So my question is:</strong></p>
  
  <p>What's the best way to "kill" all active controllers before presenting the login controller?</p>