Calling close() in some cases issued two close() syscalls to one FD, which is incorrect in multithreaded programs.