AAI: fix crash at exit (#3286)