Release the correct locks and release they in the correct sequence.