Pull common code into library. Make logout script to put down hand if still up at logout.