Fixed closing down the thread of the EndpointWrapper