Can I transfer during the last year of a 5 year Master's program?
In general, most universities in the United States have a residency requirement (total number of credits that must be completed at the school that grants the degree) and/or a limit on the number of credits that can be transferred towards a particular degree.

So while you can in theory transfer at any time, you will not necessarily be able to bring all your credits with you  Similarly, if the new program has different requirements than the previous program, you may end up taking more courses in total (to satisfy these requirements) than you would have had you stayed in one program for the entire duration. (Joint B.S./M.S. programs in particular often have very inflexible timelines that make it difficult to transfer in middle without losing time and credits.)

You will have to check the policies of the school you plan to transfer to for more details, to see what this will mean for your plans. But be warned that the policies that will apply to you are those that are in effect when you first enroll - so even if you have it all figured out when you start your degree at University X, by the time you transfer to University Y, their policies may have changed.

TL;DR; while you may be able to transfer, the later in the program you transfer, the greater the likelihood of "losing" some of your past work and extending your graduation date (i.e. taking more than five years total to finish).