'How to stop Google Colab runtime without it automaticly restarting

I want to stop a Google Colab Runtime with code when the thing I want to do has ended, so I though of putting a line of at the end that would stop it from running. I have tried these, but none work. They all restart after stopping or then just give and error.

I got them from here:


import os
os.kill(os.getpid(), 9)

import sys
sys.exit()

exit()

quit()

!kill -9 -1

There is a shortcut for ending all runtimes, (It's undefined by default by I added it as Ctrl + Shift + K) and maybe I could write a program that would virtually typed these keys. But it makes a popup before ending the Runtime and I may not be there to accept the popup.

How do I do this? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source