title: Do something before reload or close in vue.js
body: <p>I have a Vue.JS application with a <code>beforeDestroy</code> method that I'm trying to use to store some data in local storage before the app closes or is reloaded.</p>
  <p>Just for reference:</p>
  <pre><code>beforeDestroy: function() {
    localStorage.setItem('preference', this.preference);
    ...
  }
  </code></pre>
  <p>However, neither closing nor reloading the app actually calls this method.</p>
  <p>How can I make sure this method is called before the app is closed?</p>