Where in task manager are you looking?
The crucial value would be the committed memory, not only the memory in use. If 40GB is being used, it’s possible that far more is being allocated.
IMHO that would indeed point to a memory leak because no way MSFS really needs that much memory.
To “reset” memory use fully, you’d need to reboot or use a program like RamMap to clear the standby list of files.