add trap for active record close.