Rather than face an almost assured dismissal, Department of Building Inspection chief Tom Hui pulled the plug himself.

“After such a long tenure as a civil servant, I believe it is now time to shift focus to my family,” Hui said in a March 11 letter to Building Inspection Commission President Angus McCarthy.

Hui’s resignation was effective the next day, before the commission could take up Mayor London Breed’s request that Hui be removed for misconduct. The commission, not the mayor, has the power to dismiss the DBI director.

Hui, a civil servant for 31 years who was made DBI chief in 2013, allegedly abused his position by providing “intentional preferential treatment and access to Walter Wong, a permit expediter who regularly conducts business with the DBI,” Breed wrote in a letter to the commission seeking his dismissal.

The allegations of Hui’s misconduct stemmed from the city attorney’s investigation into certain city departments after the arrest of former Public Works Director Mohammed Nuru on federal corruption charges.

The commission quickly selected Chief Building Inspector Patrick O’Riordan as the department’s interim director.

“We know that O’Riodan is clean,” said one senior city official close to the situation. “We can’t say the same for some of the possible candidates in the department.”

San Francisco Chronicle columnist Phil Matier appears Sundays and Wednesdays. Matier can be seen on the KGO-TV morning and evening news and can also be heard on KCBS radio Monday through Friday at 7:50 a.m. and 5:50 p.m. Got a tip? Call 415-777-8815, or email pmatier@sfchronicle.com. Twitter: @philmatier