It varies with the closing time of MGM.
Figure about 45 minutes to an hour after the MGM closing time.
The boats are much stricter about "shutting down the docks" on a time-table than the buses.
If you miss the last boat all the way to MGM, you can take the boat to Boardwalk and walk to MGM from there (about 12-15 minutes).
Or walk all the way from Epcot to MGM (20-30 minutes), or walk to the front exit gate of Epcot and take the bus from EPCOT TO MGM.
Just before you board the boat from MGM to Epcot, ask the crew for the last-boat time. You can then decide if you want to drive to Epcot or leave the car at MGM.