I researched quite a bit on this and was able to find the solution.
I used numberOfMonths: [3,5] and then with the help of this link , tweaked the monthDiff logic to find the number of months to be removed from final calendar.
I found the class that datepicker uses to show each month div.
Then, used slice and remove functions to remove the unrequired months.
//Add 1 to difference as we require the month with endDate too
$("#datepicker > div > div.ui-datepicker-group").slice(requiredMonths - totalMonths + 1).remove();
Please find the jsfiddle for the same.