As @Ramiro Lafuente pointed out in a commentcomment, there's a gap in this proof.
You're apparently using the first edition of my Smooth Manifolds book. The problem is fixed in the second edition, because the closed subgroup theorem is proved before this theorem.
Meanwhile, some years ago I posted a correction in my errata list for the first edition, which you can find here.