Whenever by reason of any jail being on fire, or any building contiguous, or near to a jail, being on fire, there shall be reason to apprehend that the prisoners confined in such jail may be injured or endangered by such fire, the sheriff or keeper of such jail may, at his discretion, remove such prisoners to some safe and convenient place, and there confine them, so long as may be necessary to avoid such danger; and such removal and confinement shall not be deemed an escape of such prisoners.