Can a landowner charge a dead person for renting property in the U.S.? Let's say my grandma died 4 months ago and the landowner only discovered that she was dead just now, can the landowner charge my grandma for 4 months of rental in the United States or is this illegal and can only force her to pay the rent of the month before she died?
A person's contractual rights and obligations remain valid past their death, so if the landlord dies, their heirs cannot then kick out the tenant, and likewise if the tenant dies, their estate still is liable for unpaid past and future rent. That means for example that the person cannot be evicted, the landlord cannot take their property or enter without permission save for the standard emergency conditions. The tenant (or their estate) remains liable for rent until the lease terminates. If the lease has a clause to the effect that the lease terminate at the end of the month when notice of death is given, that defines when the tenancy ends and therefore when rent isn't due – relevant to a yearly lease, and the question of whether the estate would be on the hook for a full year of rent (it also depends on whether subletting is allowed).
Yes. Your grandmother's estate is responsible for the rent.
In fact, your grandmother's estate is entitled to continue renting the apartment for a reasonable amount of time as is needed to wrap up the affairs of the estate.
Those affairs, at the very least, include gathering possessions and papers, arranging appropriate off site storage, and transporting those articles there. Or, promptly selling or disposing of articles, but it would be foolish to allow this to become a drawn-out affair, as storage units are cheaper than apartments.
So not only is it reasonable for the estate to rent the apartment for a short time, it is expected. The estate must hand over the apartment in the usual fashion - removed of all items and broom clean, per state law and/or a lawful rental agreement.
The estate is the "legal object"* formed when a person becomes deceased. It is the owner of all the deceased person's assets. It is obliged with wrapping up the person's affairs, settling the person's debts, and distributing the person's assets according to the will, living trust, or state law.
* well, not quite. There are subtle differences that are way too picayune for a general overview like this one. But it works the same way as a trust or corporation: the estate has its own assets and debts, and there are humans who manage the estate's affairs, but that doesn't make the assets (or debts) theirs.