Fix bug with abort functionality

Check the commit for details