Driving with an open trunk is probably a violation of the California vehicle code. And, even if it is not a violation, the officer can argue that he felt it presented a significant safety risk, which justified him in pulling you over...