The filing deadline for Massachusetts personal returns or extensions is April 17, 2018. Massachusetts automatically gives you a 6-month extension to October 15, 2018 if you don't owe taxes on your Massachusetts return.
If you expect to get a refund (or owe no additional taxes) on your Massachusetts return, you do not need to fill out a separate Massachusetts extension form.
However, if you owe additional Massachusetts taxes, you'll need to file your extension and submit payment by April 17, 2018 to avoid penalties. You can either print and mail Massachusetts Form M-4868 along with your check payment, or make an electronic payment through the Massachusetts Department of Revenue's MassTaxConnect site.
[Edited 4-17-18|9:54 am PST]