@jaseemabid I dont think we can simply let go of synchronous exceptions.

The peer threads share a common resource (Disk IO handle) which has to be a part of ControlThread as an MVar, so peer threads may take a while to finish doing disk IO and therefore ControlThread need to wait for them to exit gracefully

I used killThread to stop the listening thread because there we don't have resource sharing.

How do you plan to use STM, I can't think of a use case where it would be better than MVar

I cant think of anything other than using a writer thread and the same mechanism we used for logging. Also, replace both logging and file writer MVar with a Chanel (a mvar link list) so that read and write are decoupled and a slow disk wont slow down peer threads.