system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: What exactly happens when I click on "Safely Eject" for a USB or external hard drive?

.
gpt
When you save a file to disk or to a USB stick, it usually is not written completely at the moment of saving. Writing to disk means that your file is written to a part of your computer's memory, after which the operating system tells your program the file has been saved. In the background, the data of your file is then transferred from this *memory buffer* to the storage medium (that is: your disk or USB stick).

So after you have saved a file, parts of it remain in memory and have not yet been written out to the storage medium. However, your program has told *you* that the file was successfully stored.

When you prepare a USB stick or external hard disk for ejection, you tell your computer to finish writing out all data that is currently lingering in the memory buffer, while at the same time rejecting any new files to be written to the device.

After the buffer has been *flushed* (that is what it's called) all parts of all your file(s) are actually stored on the hard disk or USB stick and it is safe to disconnect it from your computer.

The real-life situation is a bit more complicated, because in addition to writing the file's content to the storage medium, it also takes some housekeeping reads and writes to register *where* exactly your data was stored in the file system of the external drive or USB stick.

tl;dr : pending data needs to be written out to the storage medium from the memory buffer.

Edit: removed some *actually*s and polished up lightly.