title: How do I call a controller action on the user exiting the session?
body: <p>I add a bunch of records to my table during a user`s session. Once the user exits the session (closes the window, goes to a different website etc.) I want to be able to call a function like so: </p>
  
  <pre><code>def clear_list
      Shoe.where(user_id: @user_id).destroy_all
  end
  </code></pre>
  
  <p>I know that <code>before_filter</code> enables you to call a controller action as the page loads. What can I use to call an action on page close?</p>