In any case in which an emergency endangering the lives of inmates of a state, county, or city penal or correctional institution has occurred or is imminent, the person in charge of the institution may remove the inmates from the institution. He shall, if possible, remove them to a safe and convenient place and there confine them as long as may be necessary to avoid the danger, or, if that is not possible, may release them. Such person shall not be held liable, civilly or criminally, for acts performed pursuant to this section.