error handling: remove thread from ctx