(a)where the mentally ill person is certified to have ceased to be mentally ill by the District Court within the local limits of whose jurisdiction such person resides or is kept or detained, the whole of the surplus amount shall be paid back to that person;