Fixed problem with socket close