When you patch your Server automatically, and also want to reboot the machines when a maintenance window is active, that is quite easy. Modify the Settings of the specific collection, I would recommend to use collections created for the use of maintenance window only, in this example, we have a short window of 45 minutes:
When you now deploy as example Windows Updates, and you do not suppress reboots, which is an Option when you create a deployment, you expect, that the Clients in this collection will install the updates and reboot, if the maintenance window is available.
This will work very well, till you have Users connecting on those Clients (probably Servers) and just Close the Remote Desktop session, so the session will remain opened. As long as a User Session is active, the settings from the Client restart behaviour are applied, which means, the SCCM Client Shows a message 90 minutes to the user. Those are the standard settings:
This means, that the disconnected but still active session will get a notification, that in 90 minutes the Computer or Server will be restarted. The Problem is, that the maintenance window is over, when the Client reaches this 90 Minute Limit.
If you want to get the Computer restart inside the Maintenance Window, even when a User is still connected, and the maintenance window is shorter than the temporary notification time, you have to use another value for the notification.