The U.S. Supreme Court unanimously ruled on Monday that an exception to the Fourth Amendment for “community caretaking” does not allow police to enter and search a home without a warrant.

The “community caretaking” exception originated from a 1973 case, Cady v. Dombrowski, in which an officer took a gun out of an impounded car without a warrant. The Supreme Court ruled at the time that police can conduct such warrantless searches if they are performing “community caretaking functions” in a “reasonable” manner.

Monday’s ruling, in the case Caniglia v. Strom, centered on whether that exception also justifies warrantless searches of homes. In a 9-0 ruling, the court decided that it does not, Time reports.

While Cady recognized that police perform “many civil tasks” in modern society, the “recognition that these tasks exist” is not “an open-ended license to perform them anywhere,” Justice Clarence Thomas wrote in the majority opinion. “The Fourth Amendment protects ‘[t]he right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures,’” he continued.

The suit was filed by a Rhode Island man, Edward Caniglia, after police officers searched his home and seized two handguns without a warrant in 2015. During an argument with his wife, Caniglia had placed a handgun on the dining room table and asked her to “shoot [him] and get it over with.” His wife left and spent the night elsewhere, and after not being able to reach him the next day, called the police. The police found Caniglia on his porch; he denied he was suicidal but agreed to go to the hospital for psychiatric evaluation “on the condition that the officers would not confiscate his firearms,” according to Monday’s opinion. The police did so anyway after he left.

Caniglia later sued the officers, arguing that the search and seizure violated his Fourth Amendment rights. The officers argued that their actions were legal because they believed Caniglia was suicidal. The District Court and the First Circuit Court of Appeals agreed with the police, ruling that the search counted as “community caretaking”—and that Cady had extended to both cars and homes.