I understand that the process is stopped after inserting all the database entries, however when I check the task manager in Windows, the sqlserver.exe process is still using 3.663.263 MB of memory and hasn't been released.
You may configure and manage the server memory settings.
MAX SERVER MEMORY
. https://msdn.microsoft.com/en-us/library/ms178067.aspx is a useful summary paper.
Memory values range from 32 bit to 64 bit to 128 bit.
Set min server memory and max server memory to span a range of memory values. This method is useful for system or database administrators to configure an instance of SQL Server in conjunction with the memory requirements of other applications that run on the same computer.
Use min server memory to guarantee a minimum amount of memory available to the SQL Server Memory Manager for an instance of SQL Server. SQL Server will not immediately allocate the amount of memory specified in min server memory on startup. However, after memory usage has reached this value due to client load, SQL Server cannot free memory unless the value of min server memory is reduced.