I think your response to your neighbor provided a logical and appropriate explanation for why you baked cookies for the kids. If you felt the conversation went on too long, you can always find a way to wrap it up and exit the conversation, or if you want to keep it going, you can always ask the person questions about themselves or their lives. People love to talk about themselves. Whenever I find myself in an awkward position socially, I just start asking the person questions and get them talking about themselves, or a give a nice compliment, which most people will typically enjoy receiving. If you get the sense the person doesn't want to talk more, like if they're not saying much and if you seem to be the one talking or carrying all the conversation, then politely exit and wrap it up.
Social cues can be tough, so don't feel bad... many people do have trouble reading cues. It just takes practice and learning how.