What is the role of 在 in 您要在关闭文件前保存吗？
It is part of the construction:

在....前
'before....' (used as a conjunction).

Here it means 'Before you close the file, do you want to save it?' The 在 effectively indicates a point in time, i.e., 'at' a particular time. (Literally translated into English, this would become 'at [the time] before you close the file').
This is typical of constructions like:

在...前
'before'
在...时
'when'
在...后
'after'
当...时
'when'

This tends to be a written usage and is omitted in conversation (and often in writing).