Ensure that you have signed out of all iCloud features, such as Find My and iCloud Drive, before attempting to sign out of your Apple ID. You may also need to restart your device or update to the latest OS version.