How to sign out of your Apple device remotely
Step 1. Go to iCloud.com and sign in. (If you’ve forgotten your password, you can get it reset on Apple’s main page.)

Step 2. Click the Find My app. It’ll be fairly easy to find, looking like a green-ish radar.
Step 3. Click All Devices.

Step 4. Select the device you need to remove. It should pop up on a list, hopefully not too populated with technical peripherals (like below).

Step 5. Select Remove from Account.

Step 6. Click Remove.

Once these steps are followed, the phone should be removed from the account and good for the next person to use! If you somehow get stuck, feel free to reach out to Apple for further assistance.