Set socket to nullptr when finished