Thread should be able to terminate gracefully
Formatting
Simplified, but does not work yet