A resident voluntarily admitted to a residential care facility may not be detained more than 96 hours after the time the resident, the resident's parents if the resident is a minor, or the guardian of the resident's person requests discharge of the resident as provided by department rules, unless:
(1) the facility director determines that the resident's condition or other circumstances are such that the resident cannot be discharged without endangering the safety of the resident or the general public;
(2) the facility director files an application for judicial commitment under Section 593.041; and
(3) a court issues a protective custody order under Section 593.044 pending a final determination on the application.