When a county jail or building contiguous to it is on fire and there is reason to apprehend that the prisoners may be injured or endangered, the sheriff shall remove them to a safe and convenient place and there confine them as long as necessary.
A.R.S. § 31-107