Use this in the workbook module only

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Dim wks As Worksheet
    
    For Each wks In ThisWorkbook.Worksheets
        wks.Protect "passwordhere"
    Next wks
    If Not Cancel Then
        Me.Save
    End If
    
End Sub