They'll all be connected internally and probably have a square section of the lead-frame holding the chip in a way that gives good thermal contact.
simulate this circuit – Schematic created using CircuitLab
Figure 1. The general idea.
Good practice would be to connect all four pins together and run the 5 V ground to one side and the 9 V power supply ground to the other. Use a suitably heavy gauge for the motor return and let that be the only point where the two power supply grounds connect with each other. (This avoids any chance of motor return current taking a sneak path through your logic ground.)