remove tasks

and fixed bug when closing window