fixes #3890 error while deleting container used by template