I'm a sober Dad, but I found out she was 3-months pregnant when I was almost 3months into rehab. I left transitional after being 3-months. I already planned on staying the minimal 3-months, but I had a better excuse than that I just wanted to leave. If it is inpatient, they aren't going to let you leave. Transitional and sober living will allow you to leave with permission, but with transitional it will only be on one occurrence after you build up trust if they let you go. Sober living will vary.
Your kids will be fine. They won't forget who they're mother is, and if you've decided to go to rehab, then you know where your addiction will take you. Letting yourself be consumed by that won't be beneficial to your children at all. Do it for yourself, but by doing it for yourself, you're doing it for your family. Recovery is a selfish+selfless program.