Fix bug when removing S4 classes with inheritance

Since `devtools:::remove_s4_classes` iterates over classes in the package, the function `devtools:::contains_backrefs` can reference a slot on `NULL`. Added an `is.null` check to avoid this.