add exception handling for Ctrl-C.
enhance exception handling