Actually, from a pragmatic point of view, Elsa would never have learned to control her powers had the door been closed. Hans was a collaterally damaging, yet necessary catalyst to the personal change which occurred within Elsa. If Hans hadn't come, Elsa would not have become enraged and revealed her powers.
This chain of causality, although it may have caused some temporary damage along the way, ultimately resulted in the defeat of the villain and the ability of Elsa to control her powers. Had Elsa not shot Anna in the heart with ice, the "act of true love" would have never occurred. Based on evidence from the movie, we can assume that this "act of true love" was what taught Elsa to control her power. As we all know, the act of true love was when Anna saved Elsa from being slain by Hans by throwing herself between Elsa and Hans' sword, turning to ice, shattering the sword, and incapacitating Hans. Fortunately, the film was made for children, so it's not too late for Anna to survive, and she is saved. If Elsa had not learned to control her powers, she would never have been reunited with her sister, Anna, and that villain Hans would be on the loose.
In addition, not having closed the door was the best choice for the entertainment value of the film itself. Every good story needs conflict, leading to a victory of one kind or another, be it a conventional victory, a Pyrrhic victory, or a moral victory. The result of the movie was a conventional victory which resulted in the improvement of Elsa and the reestablishment of the relationship between Anna and Elsa. None of the movie's plot would have occurred if Anna had closed the door, leading to a very dry and boring story.
Therefore, I conclude that Anna should not have closed the door. Of course, this is from an omniscient perspective, and Anna could not possibly have known the outcome of her choices in this situation. However, because of our omniscience, I believe that we can appreciate the overall correctitude of the decision Anna made.