log and close