How to Use CTRL+D To Close A PowerShell Window

If you’re familiar with using CTRL+D to exit out of your shell and want the same functionality for your PowerShell, here’s how to do it.

Open your PowerShell profile (Documents\PowerShell\Microsoft.PowerShell_profile.ps1):

notepad $PROFILE

and add this line:

Set-PSReadLineKeyHandler -Key Ctrl+d -Function DeleteCharOrExit

That’s it. Now reload your profile (or open a new terminal):

. $PROFILE

Now you can close your PowerShell window by pressing CTRL+D like in other shells.