Any person who is surety upon the official bond of any state officer or employee may discharge himself of such suretyship whenever he is in danger of being made liable on such bond and has no adequate remedy against his principal in consequence of his inability to discharge such liability, upon his making an application in writing setting forth such facts.