Ensure git delegate is closed before replacing