Unregister directory after window closes.