Changed Server and Client to use only 'shutdown' since it's apparently the only function that guarantees a disconnection; using it in combination with 'close' doesn't seem to work.