Show-InstallationRestartPrompt - SCCM Error 10021

When deploying an application with the (Show-InstallationRestartPrompt) SCCM is reporting error 10021. I figured out that SCCM gives this error if users click start and restart instead of clicking the restart now button on the Power Shell window. Is there a way to fix this? Is this a bug? So SCCM is seeing a unexpected restart because the user restarted the PC through windows instead of the Show-InstallationRestartPrompt box.