fixed problem with closing the application while apd is running
tiding up