Creation of the thread to handle request and closing of the socket