The first switch is a 2 way for the hallway. The 2nd switch is for the eating area of the kitchen, the 3rd switch is the issue. It is in the working area of the kitchen and had a light with a fan. We want to replace it with just a new light fixture. There are 3 black wires and 3 white wires that were connected to the old fixture. There is a red wire that is not used here. One of the black wires remains hot when this light switch is turned off and if not used none of the lights work. How do I connect the new light so it will work with the switch and shut off? The hall light and eating area switches are in the on position in the photo so I could take the photos.
Was everything working correctly before you removed the fan? All you want to do is replace the fan with a light fixture? If you have everything wired the way it was when everything was working and you removed the fan you should now have three wires. One white and I'm guessing from your description two blacks. One of those blacks provided continuous power to the fan so it would always operate whether the switch was on or not. You won't need that wire, put a wire nut on it. You should now have a black and a white left, those will connect to the black and white on the new light fixture. If I misunderstood or if you mixed the wires up then you may want to post a better picture of the ceiling box without the bracket as it's hard to see where the wires come from.