_end function now runs on state END_STATE.