closing console correctly