fixed closing implementation