Manage termination of the program