People rarely stay the full 3 hours, other than family and extremely close friends of the deceased. In many cases, the family doesn't want you to stay the whole time due to crowding issues - depends on the turnout. Taking kids is not usually a good idea. They don't know what to say/do, they may see their friends and want to play, and the grieving family doesn't need that. In cases of an open casket, that's an entirely new problem/issue to deal with and you need to decide if your kids are ready for that.
So, go, pay respects in the receiving line, sign the guest book, and then if you want to chat with people you may know, fine. Otherwise, you can leave without saying goodbye to the family - they don't need to know when you leave as they will be receiving others.
As others have said, if it's at someone's home, then you can stay longer as usually there is food and an expectation of more relaxed surroundings.