udf: Fix race between write(2) and close(2)