fix close and error events