but it was after I had saved and closed the program.
unfortunately that is not how windows works.
There is a reason why Windows has a function (and requirement) to tell it to unmount any external drive before it is physically disconnected (it's one of the symbols next to the clock in the taskbar).
When you tell windows to save anything, it is first saved into the cache, not saved physically. That is because physically saving data is slow but don't needs windows attention - the electronics of the drive handle that part of transfering data from its cache to the physical device.
One of the functions of the "shutdown" is actually for windows to wait until all drive electronics tell it "cache transfered" before cutting power to those devices. And it's basically the same with that unmount, a function to wait until the cache is transfered before sending a message to the user "you can now remove the device".
If you remove a device before that timeout has completed, part of the data is still in the cache (which is RAM that requires power) and lost when the power is lost.
Check your SD-card-drive. Its device driver should have a setting to either optimize for load times or for hot-swapping (it might be named differently in your driver). If optimizing for hot-swapping the device cache is disabled and all data directly saved physically - which will take longer (including forcing your programs to wait until that longer savetimes are completed), but it will prevent such data loss even if you eject without unmounting/waiting.
It will not save that data if you get impatient and take the drive before the program is finished however...