Add a close log button

Also, replace many "cout" by "debug"