Deregister streams before exiting python