I have inspected this SO question on how to gracefully close out the asyncio process. Although, when I perform it on my code:
async def ob_main(product_id: str, freq: int) -> None:
    assert freq >= 1, f'The minimum frequency is 1s. Adjust your value: {freq}.'
    save_loc = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', 'ob', product_id)
    while True:
        close = False
        try:
            full_save_path = create_save_location(save_loc)
            file = open(full_save_path, 'a', encoding='utf-8')
            await ob_collector(product_id, file)
            await asyncio.sleep(freq)
        except KeyboardInterrupt:
            close = True
            task.cancel()
            loop.run_forever()
            task.exception()
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            error_msg = repr(traceback.format_exception(exc_type, exc_value, exc_traceback))
            print(error_msg)
            logger.warning(f'[1]-Error encountered collecting ob data: {error_msg}')
        finally:
            if close:
                loop.close()
                cwow()
                exit(0)
I get the following traceback printed in terminal:
^C['Traceback (most recent call last):\n', '  File "/anaconda3/lib/python3.7/asyncio/runners.py", line 43, in run\n    return loop.run_until_complete(main)\n', '  File "/anaconda3/lib/python3.7/asyncio/base_events.py", line 555, in run_until_complete\n    self.run_forever()\n', '  File "/anaconda3/lib/python3.7/asyncio/base_events.py", line 523, in run_forever\n    self._run_once()\n', '  File "/anaconda3/lib/python3.7/asyncio/base_events.py", line 1722, in _run_once\n    event_list = self._selector.select(timeout)\n', '  File "/anaconda3/lib/python3.7/selectors.py", line 558, in select\n    kev_list = self._selector.control(None, max_ev, timeout)\n', 'KeyboardInterrupt\n', '\nDuring handling of the above exception, another exception occurred:\n\n', 'Traceback (most recent call last):\n', '  File "coinbase-collector.py", line 98, in ob_main\n    await asyncio.sleep(freq)\n', '  File "/anaconda3/lib/python3.7/asyncio/tasks.py", line 564, in sleep\n    return await future\n', 'concurrent.futures._base.CancelledError\n']
and the code keeps running.
task and loop are the variables from the global scope, defined in the __main__:
loop = asyncio.get_event_loop()
task = asyncio.run(ob_main(args.p, 10))
