Change background color when getting to a position

Im making a game with a rocket. It starts on the ground and goes into space.But i need the background to change when im getting out of the earths atmosphere. So it slowly changes to black. How do i do that?
If you can’t make it change slowly, then just tell me how to make it change when getting to a speciel position.

Have a aphere collider around the earth marked as trigger… When u leave the collider simple change the camera background color to black…

eg.

void OnTriggerEnter(Collider col){

if(col.name == "Earth"){
Camera.main.backgroundColor = Color.blue;
}else{
Camera.main.backgroundColor = Color.black;
}
}
void OnTriggerExit(Collider col){

if(col.name == "Earth"){
Camera.main.backgroundColor = Color.black;
}
}

you can lerp the color value from blue to black for fade in effect