Choose the slowest shutter speed available with a flash in mode P or A.

Regardless of the setting chosen for Custom Setting e2 [Flash shutter speed], shutter speeds can be as slow as 30 s in modes S and M or at flash settings of slow sync, slow rear-curtain sync, or red-eye reduction with slow sync.