The following is an excerpt from The Penguin Guide to the Superstitions of Britain and Ireland by Steve Roud.
In many areas of Britain and Ireland, when a death occurred in a house, the family cats and dogs would be removed immediately:
The household companions of dog and cat were rigidly excluded from the stricken house; indeed, it was not uncommon for the cat to be imprisoned beneath an inverted tub, for it was believed that if either of these animals should jump or cross over the dead body, the welfare of the spirit of the deceased would certainly be affected. S. W. Scotland Wood (1911)
The reasons given for this exclusion are not always exactly the same. The rational explanation is that animals left with a corpse might maul it is some way, or worse. But this does not explain the very real fear evinced even when the body was already in its coffin or when the funeral procession was underway. If a cat or dog did succeed in jumping on to or over the corpse, it was immediately and unceremoniously killed.
The custom was already widespread in the eighteenth century, and is probably much older. Most examples are reported from Scotland and northern England, but elsewhere in England a different belief held sway which would seem to obviate the need for deliberate exclusion of cats as it maintained that they would not stay in a house where death was approaching or had recently occurred:
Cats were valuable, too as able to forecast approaching death. When a person lay seriously ill at home the family cat refused to stay indoors, then it was certain that the sick person would soon die. Cambridgeshire Porter (1969)
A number of beliefs like this centre on the ability of cats and dogs to predict a coming death, either by natural but unexplained sense, or by a supernatural ability. Dogs howling outside a house where a sick person lies, or a cat refusing to stay in such a home, are both seen as prime examples of these animals’ uncanny abilities. In one instance, the pet’s sense extended beyond the bounds of the house:
(22 November 1930) She told me an odd thing. Bubbles, Mrs. Fawssett’s cat, had been curled asleep on the rug, very much a la cat. Then suddenly he stared up. His eyes glaring his fur on end, made frantic efforts to get out and when he did rushed to Mrs. Fawssett’s room which was empty as she’d been taken to Dr. Boyle’s. Cecil was so impressed by this that he made a note of the time—a quarter past four– and this, as they learnt later, was the exact time that Mrs. Fawssett died. Sussex Dudeney (1998)
It is said that the house cat can tell whether the soul of the dead person has ‘gone to heaven or hell: If immediately after death the house cat ascents a tree, the soul is ‘gone to heaven’; if it descends, the soul is ‘gone to hell’. Wales (1909)