unify cleanup in close method and on automatic hideEvent