Because your loss reawakened my pain, I didn't make enough effort to try to ease yours, Peter.
You feel guilty for two reasons, i.e. your last words to Cookie were harsh and you failed to comfort him while he was dying.
Few, if any, pet owners or parents are going to get through life without speaking harshly to their pets or children. Often, harsh words are necessary to get a point across, and are more often than not for the wellbeing of the pet or child. For example, although an instinctive way of joining a pack, rolling in poo is unhygienic and a way of picking up diseases from other dogs. You were right to try to discourage Cookie from that. The fact that he died before you could say something nice to him was just very bad luck and no fault of yours.
Yes, with hindsight, perhaps it would have been good to comfort Cookie while he was dying. However, you were in shock yourself. Although as a teenager you may feel that you are an adult, one day you will realise that right now, you are still a child. Even adults rarely do the best thing while they are in shock and/or grieving, and you are still both. You are a victim of the accident, just like Cookie, and are not to blame.
Nothing I have written may change how you feel, and I can't promise that the event will not be painful whenever you remember it. Remember, though, that unlike yours, Cookie's pain is now over. It would have been better if his last moments had been as happy as the life he had with you, but the fact remains that he did have a happy life with you. His happy life lasted far longer than his sad death, so spend more time thinking about the happy times. And, like I said, telling him how you feel may help, even though he has passed on. Your emotional wound will heal, even if leaves a scar.