When you near the end of medical school you will find out your residency on whats called match day. Before match day Med students and interns alike apply and interview at Residency programs to try and get their top choice of program, usually people self select in that they are sure they are likely to match a specific specialty because of competitive Step 1,2's ect and Honors Rotations however they will be told where they will be doing their training (boston,Maine,detroit,ect) according to who wants them at their residency program. So if you were to go into FM and hated it you could apply next year for another residency program and even another specialty. Your chances will likely be reduced at matching because you are already in a program and you will have to explain why the switch in specialty. It would be increasingly difficult if you were not originally a competitive applicant for whatever specialty you are newly pursuing because you'll be competing against people who are competitive and didn't make the mistake of choosing a specialty they hate(most some people can't help this fact though residency directors probably don't care about that).
Dislaimer: I am no med student im just an Undergrad student but I have done my bid of research, some one with more direct experience will likely chime in shortly.