Not only are the FA's actions legal, you would be committing a felony offense if you left against instructions.
This is quite simple - if you're on board a plane, disobeying instructions from a member of the flight crew is a felony under federal law. Of course, you might be able to argue in court that those instructions were completely unreasonable, etc., and maybe the jury would be convinced by this in some cases, but it's a very dangerous game to play. And besides all that, you will get arrested and probably charged in any case, which will be a massive inconvenience.
This makes sense, too - there's lots of cases in which you, as a passenger, won't have the training and the information to make a good decision. The flight crew is responsible for your well being while you're on board the flight (and whether or not the door is open makes no difference), so they will have to make decisions for you.