You can fix this by not automatically charging at the end of a trial, and sending an email instead to ask if they still want to keep the account, and closing the account or charging them based on their action at that time. I didn't say anything about automatically charging anyone necessarily. This is more about using credit card entry as a barrier to entry that gets you more of the type of users that you want (ones who are interested in your product and likely to pay you).
Also, if someone gets charged at the end of a trial because your code is set to auto-bill them and they forgot, it's not like you can't refund them. Not doing so would do more harm than good. You only want to bill people who are actually using your product.
You definitely shouldn't use this as a tactic if you want to have a viral product. This is specifically about web apps.