Getting credit while not having anyone else along is a coincidence.
When the bosses die, they are supposed to give credit to every player within a certain range of them - whether you participated in the battle or not is irrelevant.
However, at the same time the credit is being awarded, the NPC is deleting itself.
Whether you get credit or not depends which code finishes executing first. It is random.
If you don’t get credit, try again. There is nothing you can do to make it more likely to work.