In the bedtime shema, some siddurim have the bracha of Hamapil printed immediately before the paragraph of shema, whereas others have it printed at the very end of the bedtime shema prayers. What is the reason for each practice? Are there specific communities that have a minhag to do one or the other?
The minhag to say Hamapil at the end is so the beracha is semucha to (just before) sleep. That is that there should be no hefsek (break) between the beracha and falling asleep.
The minhag held by the Gra and other achronim is to say Hamapil first. They reason that the psukim said afterwards are not considered a hefsek.
I am basing what I wrote on Siddur Vilna (Mesores) page 245.
I'll add from memory that it is considered good to fall asleep while saying psukim. If you were to say Hamapil at the end, well, you might not ever make it ...