In this instance, I agree with one of the previous comments that the rats could have been trapped and released elsewhere, instead of killing them. However, that is an ideal solution, and there will be occasions where there is no choice but to kill the pests in question, such as when it comes to cockroaches, ants, termites, bees, and such.
In these types of situations, we really have no choice but to exterminate, as leaving them as they are will result in the place being unlivable, unattractive, and even unsafe. Something similar had happened to my dharma centre before, so with a heavy heart and good motivation, a group of students performed a series of prayers including some medicine Buddha prayers, for the pests to be blessed with a good rebirth before we called in the exterminator.
The most ideal situation of course, would be if we kept our dharma centre well maintained, clean and neat, is that the pest situation can be avoided as far as we can control. After all, prevention is better than cure, isn't it?