That's a known problem in stl1 phones.
Temporary fix is to drain battery fully and remove battery from phone. Leave it for an hour. Again insert the battery and charge. This fixes it temporarily for me. Now switches off around 12-18%. Better than switching off greater than 30%.