I see that this got turned into an issue here. It is indeed because flushing waits for the write to complete. See my response to the issue for a more in-depth explanation.
Unfortunately, it is not possible to make the write_all
call wait for the spawn_blocking
call to complete due to its poll_*
based design.
We may have to think about a way to have the runtime always wait for file operations when shutting down.