python implementation of the shutdown delay script