[z1867] Prevent removing template bgs from visible bg list

Fixes a crash when shutting down mangos

(based on commit [s1431] - 7af2722)