Properly shutdown webif socket when ending thread