I believe this is because player data and world data are stored separately. I recall doing a similar glitch where you mine blocks then quickly pause and alt-f4 in order for the blocks to dupe.
This is indeed the reason, but also because saving chunks takes longer so when you kill the process it doesn't have time to save them - this is also a VERY good way to corrupt your world (newer versions in particular have chunk corruption issues when simply reloading a world normally, which may be directly related to an issue with the client-server shutdown process which is responsible for many other issues; shamefully, I implemented a reliable fix in TMCW over 6 years ago and IMO 1.16 should have NEVER been released until they fixed it given how bad it has become based on the number of duplicates on various related reports, ironically, the older ones were closed as fixed). In any case, force-killing a process will cause undefined behavior and you may as well just open to LAN and enable cheats to give yourself items if you want to duplicate them (this even works in Hardcore, and technically you are still duplicating items if you use pick-block on an item to pick up a stack and/or spread it across multiple slots). Of course, any method is cheating.