adding terminatelistener