The issue is:
- A program icon is created in the dock for an open program.
- Later, that program is closed, but the icon remains in the dock.
- When I open a new instance of that program, a new icon is created and the old icon persists, unused. Right clicking the new icon confirms it is for the active window. The old icon does not correspond to any active program (and can be removed from the dock from the context menu).
This happens for several programs, including Firefox and Eclipse. It happens even if the binary and its location are completely unchanged. It also happens when restarting the computer (when OS X tries to restore the previous windows).
It's rather annoying because it makes "keep in dock" useless.
Unfortunately, I cannot determine how to accurately reproduce this. It seems to happen sometimes and not others. As well, not all programs seem to be effected (this happens often with Eclipse and Firefox, but never with Sublime Text or Terminal).
How can I force OS X to use the same icon for the exact same program? Alternatively, if there is no way to fix this, how can I prevent OS X from keeping icons in the dock after the program is closed?