You did not say which OS you are using but based on the problem I suspect you are using Windows.
You should turn off the "QuickEdit Mode". This is what usually causes the problem (someone bumps the mouse an inadvertently locks the console, thus causing the app to hand the next time it attempt to perform output).
Or in production you should really be setting the app server to run as as service. Then there is no console window and this problem is avoid altogether..