add onclose event