As a general rule, it is best to have the "Off" trigger zone two tiles away from the door, instead of one. That way, you have no chance of getting stuck when it closes.
Take note Flash's picture of the animation has only two frames, not three. If you use all three frames, it will not work.
__________________
|