Add a proper cancel implemenation (respecting threads etc)