Close network file descriptors when finished with them

These modifications help ensure that socket fds are closed when finished/closed.

This makes it so that the process's file descriptors will not be easily exausted in normal course of use.

(Although not mentioned in the commit messages it also fixes a bug which would segfault when accessing closed, deallocated send-sockets (modesSendAllClients) which were not written to, and then opening a read-socket (modesReadFromClient); the socket would be automatically freed by modesFreeClient, and then modesReadFromClients would try accessing the freed client struct, segfaulting the program. This was corrected by adding the modesCloseClient function, which closes the client connection and marks it as invalid, and then clients are only actually freed later).