You can do this (see screenshots of Firefox Options)
Clear cookies when closing Firefox
You can whitelist your trusted sites using Exceptions
Whitelist trusted sites
enter image description here
If you want to sync these settings across Firefox on different devices you can use a Firefox account (I can't add the 3rd link as I'm newbie on this site).
==============
Following earlier problems with unexpected cookies remaining in the Firefox browser I have retested on 2 Windows 10 machines.
One using Firefox beta (55.0b13) and Firefox (55.0b13) developer edition.
In both cases they cleared unwanted cookies from the browser after closing all the tabs and then
restarting the browser.
Sites specified in the Exceptions - cookies kept their cookies.
Given I had problems with Win 7 and Firefox 54 before it shows you need to check your browser cookies periodically
to ensure things are working normally.
I had less success syncing exceptions (i.e. the list of sites that are allowed to keep cookies).
However, that is probably down to my lack of experience with this feature.