Nikkei posts record quarterly gain as US stocks hit 52,000 milestone