His fellow cops can't believe he's retiring. After all, Bastiani is only 79 years old.
"Marty came into the police department two years before I was born," San Francisco Police Chief Greg Suhr said.
Bastiani's been a cop for 56 years. He would have qualified for his pension 25 years ago. He's served under 18 police chiefs.
"I was waiting for that phone call to be chief, but I never got that phone call so I figured I would stay where I was at," Bastiani said.
Bastiani spent more than four decades working in the sex crimes unit. He says the toughest part was being with the victims.
"You see how they've been injured, you see what effect it has on them, not only the victims but the families they have," Bastiani said.
The inspector has two silver and two bronze medals. He's had some close calls too, including the time he and his partner disarmed a suspect when he aimed a shotgun at them.
"My partner says, 'This is loaded. I says, 'So is this one.' I pump out the shells. He had two shotguns in bed, waiting for us," Bastiani said.
It's no wonder Clint Eastwood is one of his favorite stars. A stagehand gave him the chair Eastwood used at his desk when they shot Dirty Harry at the Hall of Justice.
So why is Bastiani retiring after all these years? It's all because of the day he bumped into a young cop.
"I says, 'I think I worked with your father,' and he says, 'Yeah and you worked with my grandfather,'" Bastiani said. "I figured I'd better not stick around working with his great grand kids."