added event cleanup
added close event