fixed a bug which can cause the closed event will be fired multiple times