OS X 10.8.5: Can I move icons around in the dock and not have them stay there when the apps are closed? Whenever I drag an open application's icon in the dock to another place in the dock, it thinks that means I want it to stay in the dock even if the app closes.

Is it possible for me to change this behavior? I like to arrange my icons in a certain way, but I don't like icons in the dock whose apps are not open.
You can remove all closed apps from the Dock (even if they are set to 'Keep in Dock') with the following command:

defaults delete com.apple.dock static-only


You can assign a hotkey to run this, or set up a launch agent to run this regularly.