close simSocket only if it was created before