Skip to content
// Forms · Apps Script

Close a form automatically at a deadline in Google Forms.

Use Apps Script setAcceptingResponses(false) and a one-shot time-based trigger to shut down a Google Form at an exact deadline, without staying logged in.

I want my Google Form to stop accepting responses at a specific date and time without me having to remember to close it manually.

The script

copy · paste · trigger
closeFormAtDeadline.gs
Apps Script
// Run scheduleFormClose() once to arm the trigger.
// The form closes automatically at your chosen deadline.

var FORM_ID = 'YOUR_FORM_ID_HERE';
var DEADLINE = new Date('2026-07-01T17:00:00'); // 5 pm UTC

function scheduleFormClose() {
  // Subtract 10 minutes so the trigger fires before the real cutoff
  var fireAt = new Date(DEADLINE.getTime() - 10 * 60 * 1000);
  ScriptApp.newTrigger('closeForm')
    .timeBased()
    .at(fireAt)
    .create();
}

function closeForm() {
  var form = FormApp.openById(FORM_ID);
  form.setAcceptingResponses(false);
  form.setCustomClosedFormMessage('Submissions are now closed. Thank you.');
}

Need a variant? Gnaw writes a custom version from one sentence — fields, triggers, edge cases handled.

Walkthrough

Where to put the script and how to arm it

Open your Google Form, click the three-dot menu in the top-right, and choose Script editor. Paste the code into the editor, replacing YOUR_FORM_ID_HERE with your form's ID (the long string in the form's URL between /d/ and /edit). Set DEADLINE to the exact date and time you want the form to stop.

Save the script, then run scheduleFormClose() once from the editor toolbar. Apps Script will ask for permission to manage your forms and triggers; grant it. That single run registers the one-shot trigger and exits. You do not run scheduleFormClose() again.

The trigger calls closeForm() automatically. You can verify it was created under Triggers (the clock icon in the left sidebar) — you should see one entry pointing at closeForm with a time-based type.

Why the 10-minute buffer matters

Google's time-based triggers use at() to schedule a specific moment, but the Apps Script infrastructure only guarantees the function fires within roughly 15 minutes of that target. The actual execution could be a few minutes early or late depending on server load.

The script subtracts 10 minutes from DEADLINE before passing the value to at(). That means the trigger is aimed at 4:50 pm when your actual cutoff is 5:00 pm. In practice the function usually runs within a minute or two of the scheduled time, so the form closes well before the real deadline rather than after it.

I keep this buffer constant at 10 minutes across all my deadline forms. Tighter buffers feel precise but occasionally let a submission slip through during a slow trigger queue. Wider buffers cut into your real submission window. Ten minutes is the practical sweet spot.

Confirming the form actually closed

After the trigger fires, open the form URL in an incognito window. You should see your custom closed message instead of the question fields. setAcceptingResponses(false) is instant and persistent; it survives the browser being closed or the script container recycling.

If you need to reopen the form later (for a correction window, say), call form.setAcceptingResponses(true) from the editor or add a second scheduled trigger that calls a reopenForm() function. The state toggles cleanly.

One thing that catches people: the Responses tab in the Form editor still shows a green toggle even after the script closes it. That toggle reflects the current state correctly, but it does not auto-update in an open browser tab. Refresh the editor and you will see the toggle has flipped to off.

Want a custom version?

Describe your sheet and the rule you want. Gnaw writes the Apps Script — fields, triggers, edge cases — in one shot.

FAQ

4 questions
How accurate is the at() trigger — will the form close exactly at my deadline?
Not to the minute. Google documents at() triggers as firing within 15 minutes of the target time. In practice they usually fire within 1-3 minutes, but you cannot count on that. Set the trigger to fire 10-15 minutes before your hard deadline so a slow queue still closes the form in time.
Do I need to leave the script editor open for the trigger to fire?
No. Once scheduleFormClose() has run and the trigger is registered, Apps Script handles execution on Google's servers entirely. You can close the browser, sign out, whatever. The trigger fires independently.
What happens if I run scheduleFormClose() more than once?
You will end up with multiple triggers all calling closeForm() at similar times. That is harmless (calling setAcceptingResponses(false) on an already-closed form is a no-op), but it creates clutter. Check the Triggers panel and delete the extras, or add a guard that checks for an existing trigger before creating a new one.
Can I use this to close a form based on response count instead of time?
Not with a time trigger. For a response-count cutoff, use an onFormSubmit trigger: on each submission, check form.getResponses().length against your cap, and call setAcceptingResponses(false) when you hit it. The same setAcceptingResponses(false) call does the work; only the trigger type changes.
// one good script a week

Get a working Apps Script snippet in your inbox, weekly.