When God gave the Ten Commandments to the Jews, he said, “You shall not commit murder.” (Exodus 20:13) Yet even under the Law of Moses he provided safety for those who killed accidentally.
The main passage about killing, though, is Genesis 9:3-6. “Every moving thing that liveth shall be meat for you; even as the green herb have I given you all things. But flesh with the life thereof, which is the blood thereof, shall ye not eat. And surely your blood of your lives will I require; at the hand of every beast will I require it, and at the hand of man; at the hand of every man's brother will I require the life of man. Whoso sheddeth man's blood, by man shall his blood be shed: for in the image of God made he man.”
Notice several things about that passage. First, it allows man to kill animals and plants, with the only restriction that he not eat animal blood. Second, God does not even approve of animals killing man. Third, God prohibits man killing man.
So can we kill bugs? Although the command to the Jews not to commit murder does not specify that it only applies to people, the context clearly shows that it is talking about man’s relation to man rather than to animals. God clearly allows killing for food. God did not rebuke Samson (Judges 15:5-6) or David (1 Samuel 17:34-37) for killing to protect themselves or others (including livestock). So we should be able to kill mosquitoes and flies that are direct threats. There is nothing that would say or imply that it is a sin to kill bugs just because they are bothering you or for any other reason. It might be wrong to do so in a cruel manner, but that would relate to the attitude and not the action itself.