Yes, it is legal to end someone's employment while they are out on medical leave. FMLA is a federal law that requires job protection for 12 weeks. (There are limited states and employers that may provide more than 12 weeks but the majority provide 12 weeks and if you belong to a union you'd want to check with the union as to this as well).
After FMLA is exhausted the employer is under no obligation to continue employment. If an employer chooses to terminate your employment then you are no longer on medical leave as you are no longer an employee. However your STD and/or LTD may continue depending on the specific plan under which you are covered. There are some states that have state STD and those are CA, NJ, NY, RI, PR
Many employers must cease employment once FMLA is exhausted due to internal protocols and practices as they are not able can not retain workers "on the books" indefinitely. The letter they sent you was 100% appropriate. In fact I'm in the same boat.
I went out of work in May of 2009 and was on STD through my employer. I was later sent the same letter and my position has been eliminated (which I expected due to the decline in performance of my company and the other position eliminations nationwide as well). However, I remain on STD until I recover or until the STD benefits are exhausted. In my case the STD was exhausted in October and my LTD began in November. LTD will continue as long as I remain disabled. Most STD and LTD plans are based on the being employed on the date you became disabled.
Example: John breaks his leg April 2, 2009 and applies for STD and is awarded this April 15, 2009. John's employer files for bankruptcy and closes the doors May 1, 2009 but John's leg requires extensive surgery and rehabilitation. In most cases his STD continues until he is released to return to work (even if there is no job to return to) or he exhausts his benefits - whichever happens first. The existence of his employer is not an issue.
STD and LTD only continue so long as the person is disabled. It is not dependent on whether there is a job to return to. Once you are deemed able to return to work - even if there is no job to go back to - then benefits will end. Be sure to request from your employer a copy of the STD and LTD plan documents so you can have these to review. There are limited cases where STD benefits end when employment ends but this is rare in my experience (15 years in the industry). If you are getting STD from an insurance company (your employer paid the insurance company either premiums or a fee to administer STD) then any decision on being disabled is between you and the insurance company.
Let me know if I can clarify this in any way.