What causes this failure at the end?

I recently bought a 3D printer for my son and when he tried to print this dragon it spewed filament everywhere towards the end of the print. What causes it? What can we do to prevent it in the future? Sorry, new to printing and figured this might be a good place to ask first. Cheers

I recently bought a 3D printer for my son and when he tried to print this dragon it spewed filament everywhere towards the end of the print. What causes it? What can we do to prevent it in the future? Sorry, new to printing and figured this might be a good place to ask first. Cheers