See the paragraph "Stop using iCloud Photo Library" on this Help page: Use iCloud Photo Library to store photos in Photos on Mac - Apple Support
If you simply disable iCloud Photo Library on your Mac, the photos will remain in iCloud:
Important: If you turn off iCloud Photo Library, you’ll be prompted to select “Download Originals to this Mac” in the iCloud pane of Photos preferences, so all your original photos can be downloaded from iCloud to your Mac. Be sure to allow time for your originals to download before turning off iCloud Photo Library completely.
- Choose Photos > Preferences, then click iCloud.
- Deselect the iCloud Photo Library checkbox to turn it off.
After you turn off iCloud Photo Library, the Photos app on your Mac can’t access your photos or videos stored in iCloud. Any edits you make to photos on your Mac won’t appear on your other devices, and any new photos you take will not be added to Photos on your Mac. Your library remains in iCloud and available to other devices that use iCloud Photo Library.
To turn off iCloud Photo Library on all your devices, open the iCloud pane of System Preferences, click the Manage button, then click Photo Library. Click “Disable and delete.”
WARNING: If you turn off iCloud Photo Library on all your devices, your photos and videos will be deleted from iCloud Photo Library in 30 days, and you won’t be able to recover them, unless you click Undo Delete before that time.