FileSink, ByteStream: do not end a native sink while its last bytes are still buffered (#39611)