I'm considering implementing the pessimistic locking pattern in a WinForms insurance quoting application using SQL Server. Before a user starts working on a quote, a record will be added to the lock table; when they're done, the record will be deleted from the table.
My question is, how do I ensure that the lock is released in the event of a failure which is outside of my application's control? I'm thinking mostly of client side network connection errors or power failures, but there are endless possibilities.