more graceful handling of close events