Stop the training gracefully

Hi,
I would like to catch the KeyboardInterrupt exception when doing training with multiple gpus, however, it seems I cant catch these exceptions. Do you know how I can do this?