Rolls back changes if an error occurred