Prehistoric climate change damaged the ozone layer and led to a mass extinction, study finds