Firefox has an option to delete cookies when you quit the browser.
The Desktop (Linux) version of Firefox also has the additional option to specify exceptions to this deletion for specific sites. Unfortunately the Android version of Firefox does not have this option (or I couldn't get it to work).
Cookies and site data (local storage) are treated the same (since a site can store a user identifier in local storage).
Local storage is a great way for a websites to store personal data. It avoids tracking and it simplifies website functionality, since the server can be entirely stateless, without storing anything for its users. On the other hand, it means that the data is device-specific and is not shared across devices of the same user.
Deleting cookies when a tab is closed wouldn't be appropriate, because cookies are site-specific, not tab-specific and browsers easily go back and forth between tabs. For example, when clicking on a link in a page that takes you to another website, the current tab is replaced by the new site. Should cookies of the old tab be deleted? What if you then hit the back button and go back to the old tab? Would you be left without cookies, presumably losing information?