How to rollback the identity seed after deadlock
I believe your best bet is going to be to use a TRY-CATCH.  I've done two things here.  First declare and get your "oldID" before your transaction begins.  This will help to keep your transaction time down and avoid deadlocks as much as possible.  Second I've put the "core" of the rest of it into a TRY block and then in the CATCH block put the reseed again.  This way regardless of the error you will re-set the seed.  I believe this will work even in a deadlock situation.

DECLARE @oldID bigint
SELECT @oldID = MAX(id) from identtest where id&lt;3000

BEGIN TRANSACTION

BEGIN TRY
    SET IDENTITY_INSERT identtest ON;
    INSERT INTO identtest (id, x) VALUES (4000,'y');
    DBCC CHECKIDENT ('identtest', RESEED, @oldID) WITH NO_INFOMSGS;
    SET IDENTITY_INSERT identtest OFF;
END TRY
BEGIN CATCH
    IF @@TRANCOUNT &gt; 0
        ROLLBACK TRANSACTION;
    DBCC CHECKIDENT ('identtest', RESEED, @oldID) WITH NO_INFOMSGS;
END CATCH

IF @@TRANCOUNT &gt; 0
    COMMIT TRANSACTION;

DBCC CHECKIDENT ('identtest', NORESEED)


All of that being said you may be better off switching your logic around a bit.  Would it be possible for you to set your "normal" inserts to start at say 20000000 and then your IDENTITY_INSERTS to start at 10000000?  This way regardless of your insert the seed will stay at the larger "normal" value.  It sounds like you are a bit far in to do this, but you never know.