Python code for shutdown