[libc] Move thread sync when closing port earlier

Summary:
This synchronization should be done before we handle the logic relating
to closing the port. This isn't majorly important now but it would break
if we ever decided to run a server on the GPU.
GitOrigin-RevId: 8004ce236795d48063c636d1ce4818ebcb526b21
1 file changed