updated server to close socket