You can install the Self-Destructing Cookies extension from the Mozilla Firefox extensions repository website. The extension is a no-restart extension and therefore it starts working without your having to re-start the browser.
After the installation, you would see a small red icon in the add-ons bar of Firefox web browser. If the add-ons toolbar is not visible, then you can use the hotkey Ctrl + / to make it visible. Immediately after the installation, it scans the cookies stored in Firefox, removes the ones not currently in use and a message is shown to the effect.
If you do not want it to automatically remove the cookies for any not-in-use website, then you can visit that website and then click on the Self-Destructing Cookies extension icon in the add-ons toolbar. A popup box would show up from where you can control when to delete the cookies or whether never to delete the cookies for that website.
From the same popup box, you can also temporarily suspend the Self-Destructing Cookies extension operation or undelete all the cookies and then suspend it. Any time later, you can click on this add-ons toolbar icon again and choose to Resume the operation for the Self-Destructing Cookies extension.
In the options for the Self-Destructing Cookies extension, you can choose the timeout grace value after which a website is considered inactive. By default the grace value is 10 seconds after which the unused cookies are removed. You can also select to have an Undo option enabled so that you can restore any cookies deleted by the Self-Destructing Cookies extension. In the settings, you can also edit a whitelist of sites which stay unaffected by this extension.
Conclusion: The Self-Destructing Cookies extension for Firefox automatically removes cookies that are not in use currently. This helps you from being tracked or hacked through your stored cookies.
You can get the Self-Destructing Cookies extension from https://addons.mozilla.org/en-US/firefox/addon/self-destructing-cookies/.