Self-locking of modes in a passiveQ-switched laser