Muni officials are making repairs to the heart and guts of San Francisco’s subway system, including vital work to overhead lines, signals, tracks and the automated train control system to prevent meltdowns like the one that choked service for a full day in April.

But the fixes come with a trade-off. Starting Monday night, service will shut down at 9:30 p.m. — three and a half hours earlier than Muni’s normal closing time. The early closures will last for about two weeks to give crews enough time to finish complex infrastructure work.

Without the schedule adjustment, Muni would have to squeeze all its maintenance into a two-hour window between the time trains pull in for the night and the moment they start rolling at 5 a.m.

“We’re really trying to consolidate the work and minimize the amount of time the subway is closed, since we know it inconveniences people,” said Gwyneth Borden, vice chair of the San Francisco Municipal Transit Agency’s Board of Directors.

She noted that the board now receives monthly subway progress reports and regular 90-day action plans from transit director Julie Kirschbaum, helping to locate faulty equipment before breakdowns and head off disasters before they happen.

During the two-week repair period, Muni will run nighttime bus shuttles to all Metro train stops between Embarcadero and Brannan streets and St. Francis Circle on the west side. Trains will run between Balboa Park and St. Francis Circle on the K and M lines, and between Ocean Beach and Church Street/Duboce Ave. on the N line. On the J line, trains will run between Balboa Park and Church Street/Duboce Ave., and T trains will loop from Sunnydale to Embarcadero and Brannan Street.

At Church and Duboce Ave. inbound J trains will become outbound N trains after 9:30 p.m., and inbound N trains will become outbound J trains.

Rachel Swan is a San Francisco Chronicle staff writer. Email: [email protected] Twitter: @rachelswan