more robust python close and shutdown. refs #117