On both PC and Mac computers there is a safe way to may sure you don’t corrupt your data.. PC instructions here from Microsoft:
Safely remove devices from your computer
If you unplug a storage device or removable drive from your computer while it’s transferring or saving information, you might risk losing some information. Windows provides a way to help you safely remove such devices.
Most USB devices can safely be unplugged and removed. When unplugging storage devices, such as USB flash drives or external hard drives, make sure that the computer has finished saving any information to the device before removing it. If the device has a small light that shows when it’s use, wait a few seconds after the light has finished flashing before unplugging it.



On a Mac, right click the drive and chose eject, OR drag the drive to the trash. It is in the menu if the drive is selected also, as shown here: