- Capture close event and save dock states.