Improved handling when threads get interrupted