Planetary nebulae are made when where a dying star has thrown off its outer layers . Among the several different types of emission nebulae are H II regions , in which star formation is taking place and young , massive stars are the source of the ionizing photons ; and planetary nebulae , in which a dying star has thrown off its outer layers , with the exposed hot core then ionizing them .