Avoiding Them Altogether
Before we start, there are a couple ways to avoid these insects even coming into your house. Keep screens on your windows and doors, so there are no openings for flies or gnats to come in. Cover all of the food you have sitting on counters inside the house. Also, avoid letting garbage or rotten food sit for more than a day in the can.
Tools of the Trade
The traditional methods to trap and kill flying insects often include shoes, books and hands. However, these may not be the most effective The surface area on some of these objects isn't much, but more importantly, they aren't the safest. Hitting a wall with a shoe could cause scuffs, and with any of these you can knock something over. If you miss, or hit something exceptionally hard, your hands could get hurt. Stick to fly swatters or a rolled up newspaper. They have better handling, as well as better results.
Things You Can Buy
There are a variety of sprays to kill flying insects, but there is one flaw with them: They aren't usually accurate and they can be messy. Because they are toxic to animals and children, refrain from using them in large quantities, and clean the area thoroughly after you do. Make sure if you use the insecticides, you aim at the insect while it is at rest. You can also buy indoor bug zappers from most home improvement stores. Most of these aren't loud or obtrusive and they get the job done. Some even come equipped with noises and smells to attract the bug to that space. You can use flypaper strips indoors, but they are not usually favored because of the appearance.
Tips and Tricks
If you have a can of hairspray in the house, this can be your best friend. Hitting a flying insect with hairspray slows it down and sometimes drops it right out of the air because its wings can't function. Also, aim behind the insect you are trying to hit. Most flying insects take off backwards. Even if it is a millimeter, you will have a better chance at making contact. If you are desperate, try lowering the temperature (you can use your thermostat, or close the door and open a window for the breeze). Insects move slower in the cooler air, and are therefore easier to catch.