It means to put an end to something before it grows and causes havoc. In other words, it means to stop an object from developing and causing trouble. For eg, for the case of - a father talks to his son, who was on the verge of killing himself, and talks him into giving up the idea. In this case, the father stops the son's mentality of suicide, before he actually attempts it. So, this is nip in the buds.