Better termination of the application

Even closes bug with password generation